Clickdetector don't working or script?

Hello there, I was coding my script
but There is no error no function fired when I click on button
Script

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	player.Character.HumanoidRootPart.CFrame = game.Workspace["Lift "..script.Parent.Name]["Floor lift"].CFrame + Vector3.new(0,1,0)
end)

Thank for reading

3 Likes

ClickDetectors work differently than UI buttons, in terms of what events you can use on it.

.MouseClick is a valid event.

Well then I have no Idea :smiley: lol

1 Like

Try adding vector3 to the position, not CFrame, or multiply it’s current CFrame by CFrame.new(additional CFrame)

Try to use CFrame.new() function while changing the position of the player.

Uhm
1 of all It’s don’t show icon of clickdetector
2 of all Any function isn’t fired
3 of all Part is concolllide = true and transparency = 0

Can you show us your workspace explorer so we can see where are your things located, please.

Here
Screenshot_12

Do .position instead of .CFrame, and your scripts would be much cleaner if you didn’t name things with spaces.

What if you try to connect it with remote events? put the localscript inside startergui and connect the click detector in it on clicked then fire event from the client to script and do your thing with brick in script?

Starter gui has nothing to do with a click detector, and only a single server script is needed for click detectors.

Alright, the issue is you can disconnect the HumanoidRootPart from the body, but the rest of the character won’t follow. It’s best to use :SetPrimaryPartCFrame, which moves the full model:

script.Parent.ClickDetector.MouseClick:Connect(function(player)
   player.Character:SetPrimaryPartCFrame(game.Workspace["Lift "..script.Parent.Name]["Floor lift"].CFrame + Vector3.new(0,2.5,0))
end)

Also, I would move this into a local script, as ClickDetectors work better in that way, namely due to filtering enabled wrecking click detectors, and use a remote event.
cc @gamerobotjimmy

1 Like