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 6 years ago

I have this 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)

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 — 6y

1 answer

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

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

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

script.Parent.ClickDetector.MouseClick:connect(function()
    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 will basically do what you want the script to do when a player clicks the part.

Ad

Answer this question