I'm testing my abilities with RemoteEvents and I already suck at this. Basically I'm just trying to make a Part that when clicked on, disables CanCollide only for the user who clicked on it.
I assume to do this you need a Server to Client RemoteEvent. Or am I mistaken?
I put a Part into Workspace, and put a ClickDetector, Script, and LocalScript inside.
Part > ClickDetector, Script, LocalScript
Script:
local plr = game.Players.Player script.Parent.ClickDetector.MouseClick:Connect(function() game.ReplicatedStorage.TestEvent:FireClient(plr) end)
LocalScript:
game.ReplicatedStorage.TestEvent.OnClientEvent:Connect(function() script.Parent.CanCollide = false end)
I really just dunno why I can't get something as simple as this to work...
You're trying to edit the properties of a part with a local script. The whole point of the distinction between local a server scripts is so local scripts and interact only with the client to prevent someone from exploiting. Although I am not aware of a way to make the part selectively collectible, sorry. And if their is a way (probably is) you'll probably have to edit some specific part of the player.
script.Parent.ClickDetector.MouseClick:Connect(function(plr) game.ReplicatedStorage.TestEvent:FireClient(plr) end) --[[ So the first thing is you can't get the client on the server. Next, the MouseClick event for the click detector has a parameter which is playerThatClicked. Other than that everything should work fine. ]]
MouseClick scroll down to parameters and there is a playerThatClicked.