Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

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

Asked by 2 years ago
Edited 2 years ago

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

0
it does print part touched though tonomeow 5 — 2y
0
I need the wall to turn off cancollide client side not server side tonomeow 5 — 2y
0
Why not just do "wall.CanCollide = false" instead of "remote:FireServer()?" 9mze 193 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

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.

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. tonomeow 5 — 2y
0
I've looked everywhere and i cant figure out how to do it. tonomeow 5 — 2y
0
Sorry if this isn't the best solution, but try sending player in event and then checking if player == Players.LocalPlayer. GulgPlayer 17 — 2y
0
Please, post your code with BindableEvent. It seems like something wrong, because BindableEvent shouldn't send to other client. GulgPlayer 17 — 2y
Ad

Answer this question