Sometimes my script works but sometimes it doesn't (EDIT: the chair doesn't do anything)

The setup is kind of like a dunk tank. You push a button then a trapdoor opens. When I click the button, 5 times out of 10, it doesn’t work. I want my trapdoor to always unanchor.

Capture

I don’t know what to try to fix it.

This is the script:

-- local clickDetector = Instance.new("ClickDetector",script.Parent)

clickDetector.MouseClick:connect(function()
	for _,v in pairs(game.Workspace.Drop:GetChildren()) do
		if v:IsA("BasePart") then
			v.Anchored = false
			 end
		 end
	end)

Please help!

2 Likes

It should work perfectly fine.

Unless some other object is obstructing the ClickDetector Part then this should work.

You could also use a Proximity Prompt if you can’t fix this.

Do you get errors in output when you click and nothing happens?

Also capitalize the “connect”.

This may also be due to Roblox Physics updates, check that if you press the button (and the platform doesnt fall) if the parts in the model are unanchored.

I didn’t see any errors in the output box…

The parts were still anchored when I pressed the button.

add a statement to output a text when the button gets pressed as well, so you can make sure you actually CLICKED the button
(forgot if it was print or something)

I don’t know how to do that since I don’t know how to script (only basic stuff)

put
print(“yay”) right above v.Anchored = false

now if it doesn’t output “yay” then it means you literally didn’t click the button

I clicked it and it worked. It said yay and dropped, but when I clicked it a second time it didn’t. Neither the yay or the drop. (different tries)

ok so that means the second time the game didn’t think you clicked.
something is probably blocking the button or something

or the click detector didn’t detect

How should I fix it? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

I guess try moving things around so nothing could be blocking it?

not really familier with click detectors lol

I’ve tried before lol, it didn’t work

I don’t think anything is obstructing the clickdetector. I don’t know what a Proximity Prompt is. I think the game doesn’t think I click the button.

You may need to set the NetworkOwnership to the server so there aren’t these weird edge cases where the generated weld to the character from the seat messes with Physics replications

-- On the Server, obviously
local Drop = workspace:WaitForChild("Drop")
local CD = Instance.new("ClickDetector",script.Parent)

CD.MouseClick:Connect(function()
	for _,v in Drop:GetChildren() do
		if v:IsA("BasePart") then
			v.Anchored = false
			if v:CanSetNetworkOwnership() then 
				v:SetNetworkOwner(nil) -- 'nil' sets it to the Server
			else
				warn("Could not set Ownership for "..v.Name)
			end
		end
	end
end)

Capture LIke this? Because it didn’t work