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

How to make a clickdetector script that does this?

So, i have a script, y'know, simple script.

local player = game.Players.LocalPlayer
local leaderboard = player:WaitForChild("leaderstats")
local price = 30

    if leaderboard.Cashies.Value >= price.Value then
leaderboard.Cashies.Value = leaderboard
leaderboard.Cashies.Value = leaderboard.Cashies.Value - price.Value
leaderboard.Pointies.Value = leaderboard.Points.Value - price.Value
    end
end)

However, how can i make this script be a ClickDetector version? I already have a block with the clickdetector.

And the extra thing that is needed: It needs to work on filtering enabled.

Thanks for listening.

1 comment

1 answer

✓ Accepted answer

In a server script:

ClickDetector.MouseClick:Connect(function(player)
	local leaderboard = player:WaitForChild("leaderstats")
	local price = 30
    	if leaderboard.Cashies.Value >= price.Value then
		leaderboard.Cashies.Value = leaderboard
		leaderboard.Cashies.Value = leaderboard.Cashies.Value - price.Value
		leaderboard.Pointies.Value = leaderboard.Points.Value - price.Value
	  end
end)

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