Remote event not fires normally?

  1. Hello everybody. Does everybody know whats happening? How to fix this?

In outpit i can see “Server is ok”
But no “Client is”
and also cancollide isnt change local and server
server script

script.Parent.MouseClick:Connect(function(plr)
	print("Server is ok")
	script.Parent.RemoteEvent:FireClient(plr)
end)

Local script

script.Parent.RemoteEvent.OnClientEvent:Connect(function()
	
	print("Client is")
	script.Parent.Parent.CanCollide=not script.Parent.Parent.CanCollide
	
end)

Typically, you should not be checking for mouse clicks on the server side, it is not reliable and you can run into problems like this.

What you should do instead is check for mouse clicks on the client side, and then change the can collide of your part during a mouse click.

i tried. didnt work at alll.
Even like that so

can you show your explorer to be clearer

Capture

thats the issue cant have localscripts in the workspace

I am not sure what you mean, here’s what you can do:

-- On the client side
script.Parent.MouseClick:Connect(function()
    local currentState = script.Parent.Parent.CanCollide
    if currentState == true then
        script.Parent.Parent.CanCollide = false
        return
    end
    script.Parent.Parent.CanCollide = true
end)

what do you mean? I didnt really understand soo…

The local script should be inside of StarterPlayerScripts

didnt work . As i told you. It is not working. I tried.

You cannot have local scripts in the workspace as they do not run. For your case, do not fire any events and just change the can collide property when the button is clicked.

move the local script to startercharacterscripts or starterplayerscript and move the remote event to replicated storage

thats strange i guess. Lol, why does it work like that? Anyways thanks

no problem did you change your code for it