i have the click to earn 1+ leaderstats already but i want to have it where if you sit you can only click it so when you get up from the seat you cant click it anymore
With the humanoid.StateChanged
Event (Humanoid is the "core" part of a player.) you can detect whenever a player is sitting, walking, etc. Click detectors have a property called MaxActivationDistance which sets how far a player can click the Click Detector. If we set the MaxActivationDistance to 0 when the player is not sitting the player won't be able to click the Click Detector. Below is an example of what you could do:
local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid", 10) local clickDetector = game.Workspace.Button.ClickDetector humanoid.StateChanged:Connect(function(oldState, newState) --Setting the Click Detector to a clickable distance when the player is sitting. if newState == Enum.HumanoidStateType.Seated then clickDetector.MaxActivationDistance = 20 end --Setting the Click Detector to an unclickable distance when the player is not sitting. if newState ~= Enum.HumanoidStateType.Seated then clickDetector.MaxActivationDistance = 0 end end) clickDetector.MouseClick:Connect(function() print("Clicked!") --Whatever code you want to activate when the Click Detector is clicked end)