All those scripts share the same remote event (in ReplicatedStorage) to send the signal, so itâs fine if you have one local script in StarterPlayerScripts to receive it.
As for the server, you can make the code more scalable by having one centralised server script handling all proximity prompts, for instance, by iterating over a folder theyâre all stored in or using CollectionService to connect them.
Edit. @iQeeDEVS there is no problem with moving one instance of your local script in StarterPlayerScripts (or elsewhere).
Here is also a version of your script that goes through a list of all your parts with proximity prompts and connects them. Itâs as simple as putting all âpromptPartsâ in a folder and traversing the array returned by :GetChildren().
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local startGameRemote = ReplicatedStorage.StartGame
local promptPartList = workspace.PromptParts:GetChildren()
for _, promptPart in promptPartList do
local proximityPrompt = promptPart.ProximityPrompt
proximityPrompt.Triggered:Connect(function(player)
startGameRemote:FireClient(player)
print("fired")
end)
end
How can the client know of this script? Think about the server to client communcation. If you arenât doing this in the scope of the client how will it see it? The function is returning fired, because the server is, the server is aware, nothing else is. If it were me Iâd create a local script inside the starter player scripts, and itirate through every block you want to connect to the event. If any player does it its safe through that player. A script in workspace or in a part is highly exploitable and can be called millions of times by someone. Protect this in a remote event and make a script in the server script service. I just canât recommend anything less of that. You can acomplish anything you want in those scripts so to say you canât do that because of so many parts isnât the correct thought process.
local RS = game:GetService("ReplicatedStorage")
local intToE = script.Parent:WaitForChild('ProximityPrompt')
script.Parent.ProximityPrompt.Triggered:Connect(function(player)
RS.StartGame:FireClient(player)
print("fired")
end)
LocalScript:
local RS = game:GetService("ReplicatedStorage")
RS:WaitForChild('StartGame').OnClientEvent:Connect(function()
print("connected")
end)
The main issue is that you had an extra âendâ in the LocalScript. But another issue is that you werenât using WaitForChild. While Roblox has made steps to reduce the requirement for this, Iâd still recommend using it.
Also, make sure that your output window is open so that you can see any potential errors.
(Sorry, it looks like this answer was already given. I didnât read the replies clearly enough.)