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

I want to make a script so if a tool touch something u will get money but my scirpt down working?

Asked by 6 years ago
Edited 6 years ago

Hello,

I want to make so if a tool touch something he will get money after some seconds! This is the script i using now that are wrong:

Money = "Cash"
GetMoneyFromTree = "100"
WaitForMoney = 10

script.Parent.Touched:connect(function(hit)
    if hit.Parent.Name == "Tool" then
        script.Parent.Anchored = false
        wait(10)
        game.Players.LocalPlayer.leaderstats[Money].Value = game.Players.LocalPlayer.leaderstats[Money].Value + 100
    end
end)

That script is wrong.

Can someone help me with this script??

1 answer

Log in to vote
0
Answered by
Leamir 3138 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

Hello, Lava_Scripter!

You don't test if a item has the name of tool(if you REALLY want this, you do)

You use :IsA("Tool") to test if part is a tool

Edited script:

Money = "Cash"
GetMoneyFromTree = "100"
WaitForMoney = 10

script.Parent.Touched:connect(function(hit)
    if hit.Parent:IsA("Tool") then
        script.Parent.Anchored = false
        wait(10)
        game.Players.LocalPlayer.leaderstats[Money].Value = game.Players.LocalPlayer.leaderstats[Money].Value + 100
    end
end)

Good Luck with your games!

0
thx Lava_Scripter 109 — 6y
Ad

Answer this question