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

Change humanoid to tool? [closed]

Asked by 6 years ago

This question already has an answer here:

Change humanoid to tool?

I have a script that gives you 1 coin when a humanoid touches it. I want to change that script to where if a tool touches it it gives me one coin. 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

Marked as Duplicate by Vulkarin, TheeDeathCaster, DevNetx, and Operation_Meme

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?