Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Trouble with local script not listening when remote event is fired?

I have two localscripts in startergui and the first one listens for when a specific part is touched it fires the remote event here's the firing script:

toucher = game.Workspace.Toucher1
local remote = game:GetService("ReplicatedStorage").RemoteEvent


toucher.Touched:Connect(function(hit)
	if hit then
		print("part touched")
		remote:FireServer()
	end
end)

And here's the listener:

local wall = game.workspace.Wall

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
	wall.CanCollide = false
end)

I dont get why the wall is not turning off cancollide

3 comments

0

it does print part touched though

0

I need the wall to turn off cancollide client side not server side

0

Why not just do "wall.CanCollide = false" instead of "remote:FireServer()?"

1 answer

remote:FireServer() sends message to the server, not the client, so RemoteEvent.OnClientEvent will never run. If you want to communicate LocalScript with LocalScript use BindableEvents.

4 comments

0

Its working now but its working serverside i need it to work just for the person who touches the brick for the can collide to be off not for the person who does not touch the brick.

0

I've looked everywhere and i cant figure out how to do it.

0

Sorry if this isn't the best solution, but try sending player in event and then checking if player == Players.LocalPlayer.

0

Please, post your code with BindableEvent. It seems like something wrong, because BindableEvent shouldn't send to other client.

This discussion is preserved as it was. New answers, comments, and votes are closed.