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

ClickDetector Isn't Working when it just was?

I'm making a carlift for my friend and I tried making it so that when you click a button it would make a wall collidable and visible. But for some reason it isnt working. Here's the script(s): (This LocalScript is in StarterGui to make sure it doesn't conflict with anything)

local Wall = game.Workspace.Wall1

Wall.ClickDetector.MouseClick:Connect(function()
	game.Workspace.Wall1Event:FireServer()
end)

(This script is in Workspace)

local Wall = game.Workspace.Wall1

script.Parent.OnServerEvent:Connect(function()
	if Wall.CanCollide == false then
		Wall.CanCollide = true
	else
		Wall.CanCollide = false
	end
	
	if Wall.Transparency == 1 then
		Wall.Transparency = 0.45
	else
		Wall.Transparency = 1
	end
end)

Here is my explorer: https://imgur.com/a/w5zgTT3

1 comment

0

Try putting the remote event in ReplicatedStorage and the server script (second script) in ServerScriptService. Change stuff to fit in like "script.Parent" to "game.ReplicatedStorage.Wall1Event".

1 answer

✓ Accepted answer

ClickDetectors can be accessed by both the Server and Client, so there is no need for a RemoteEvent. You can simply have a single Script control the door's functions. Here's an example of this that you can use as a reference to fix your issue.

Here is the Explorer

Here is the Script

local button = script.Parent
local door = button.Parent.Door
local ClickDetector = button.ClickDetector
local visible = true -- Current state of the door

ClickDetector.MouseClick:Connect(function()
	if visible then
		visible = false
		door.Transparency = 1
		door.CanCollide = false
	else
		visible = true
		door.Transparency = 0
		door.CanCollide = true
	end
end)

If you have any questions or problems with this answer, let me know. I'd be happy to clarify or fix it.

Hope this helps!

2 comments

0

Thanks! I tried that before but I used a LocalScript (lol)

0

Happy to help :)

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