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

Change Humanoid touch to tool touch?

Asked by 6 years ago

I have this script that gives me 1 sand if a humanoid touches it. I want to change it so it gives you 1 sand when a tool touches it. Does anybody know how to change it?

script.Parent.Touched:connect(function(part)
    if game.Players:findFirstChild(part.Parent.Name) then
        local plr = game.Players:findFirstChild(part.Parent.Name)
        plr.leaderstats.Ice.Value = plr.leaderstats.Ice.Value + 1
    end
end)
local debounce = true
script.Parent.Touched:connect(function(part)
    if debounce then
        debounce = false
        if game.Players:findFirstChild(part.Parent.Name) then
            local plr = game.Players:findFirstChild(part.Parent.Name)
            plr.leaderstats.Ice.Value = plr.leaderstats.Ice.Value
+1
            script.Parent:destroy()
        end
    end
end)

thanks

1 answer

Log in to vote
0
Answered by
Lolnox 47
6 years ago
script.Parent.Touched:connect(function(part)
    if part.Parent:IsA("Tool") and game.Players:FindFirstChild(part.Parent.Parent.Name) then
        local plr = game.Players:findFirstChild(part.Parent.Parent.Name)
        plr.leaderstats.Ice.Value = plr.leaderstats.Ice.Value + 1
    end
end)

Something like this, I guess

Ad

Answer this question