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

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

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

1 comment

0

Make sue the door is welded it will go through the ground

2 answers

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.

1 comment

0

The door can be exploited already since an exploiter can just set the CanCollide of the door to false

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.

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