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

How do I make a simple door with a ClickDetector using a RemoteEvent?

Asked by 3 years ago

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

0
Make sue the door is welded it will go through the ground MarkedTomato 810 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

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.

0
The door can be exploited already since an exploiter can just set the CanCollide of the door to false MarkedTomato 810 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago
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.

Answer this question