RemoteEvent Fires but won't connect

Hello devs, there 2 script i made in workspace.

one normal script otherone LocalScript.

it prints Fired but not connecting.

Script:

local RS = game:GetService("ReplicatedStorage")
local intToE = script.Parent.ProximityPrompt

script.Parent.ProximityPrompt.Triggered:Connect(function(player)
	RS.StartGame:FireClient(player)
	print("fired")
end)

Local:

local RS = game:GetService("ReplicatedStorage")

RS.StartGame.OnClientEvent:Connect(function()
	print("connected")
	end
end)

(For the LocalScript)

You’ve got an unneccessary end. Try removing that.
Also try changing RS.StartGame to RS:WaitForChild("StartGame").

The problem might be that local scripts (with Legacy RunContext) don’t run in workspace if they’re not part of the player’s character.

I just deleted some parts of script thats why there i forgot one end. The scripts doesn’t have any error and still won’t connect with waitforchild

Uh i wanted run the localscript for spesific part. And i will have alot parts with that script cloned. I can’t put the script in starterchar etc rn

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
1 Like

i am garbage scripter for it… but thanks

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.

1 Like

Script:

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.)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.