Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Need to put a script into a clickdetector, but i dont know how to use them... help?

Asked by 7 years ago

I have this script:

01local player = game.Players.LocalPlayer
02local leaderboard = player:WaitForChild("leaderstats")
03local price = 30
04 
05    if leaderboard.Cashies.Value >= price.Value then
06leaderboard.Cashies.Value = leaderboard
07leaderboard.Cashies.Value = leaderboard.Cashies.Value - price.Value
08leaderboard.Pointies.Value = leaderboard.Points.Value - price.Value
09    end
10end)

I wanna make this script have a "Click detector" on it, But not only that, Because my game is filtering enabled, how to i make the script filtering enabled?

0
This is a Script with no LocalScript working. FE only makes it so localscripts can’t change other clients. brokenVectors 525 — 7y

1 answer

Log in to vote
0
Answered by
Nep_Ryker 131
7 years ago

Add a ClickDetector on a part and put that script in the part too. Then change your script into this:

01local player = game.Players.LocalPlayer
02local leaderboard = player:WaitForChild("leaderstats")
03local price = 30
04 
05script.Parent.ClickDetector.MouseClick:connect(function()
06    if leaderboard.Cashies.Value >= price.Value then
07        leaderboard.Cashies.Value = leaderboard
08        leaderboard.Cashies.Value = leaderboard.Cashies.Value - price.Value
09        leaderboard.Pointies.Value = leaderboard.Points.Value - price.Value
10    end
11end)

This will basically do what you want the script to do when a player clicks the part.

Ad

Answer this question