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

Change character touch to tool touch?

Asked by 6 years ago

I have been having trouble with changing this script

for _,v in pairs(script.Parent:GetChildren()) do
    if v:IsA("BasePart") then
        v.Touched:Connect(function(hit)
            if not script.Parent:FindFirstChild(tonumber(v.Name)-1) then
                local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
                if plr and plr:FindFirstChild("leaderstats") then
                    plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + 1
                end
                v:Destroy()
            end
        end)
    end
end

so that instead of a humanoid touching it and getting a coin I want a tool to touch it and get the coin.thanks

Answer this question