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

Can someone help with my script?

Asked by
steev 0
10 years ago

Whenever you touch the part you get given multiple swords (For example 9 swords in one touch) how could you limit this to one sword on each touch?

script.Parent.Touched:connect(function(part)
    if part.Parent:FindFirstChild("Humanoid") then -- checking if the part is a child of the character
        player = game.Players:GetPlayerFromCharacter (part.Parent) -- find the player
        Tool = game.Workspace.LinkedSword:Clone()
        Tool.Parent = player.Backpack
    end
end)
0
You need debounce. GoldenPhysics 474 — 10y

1 answer

Log in to vote
1
Answered by 10 years ago
debounce=false
script.Parent.Touched:connect(function(part)
if debounce==false then
debounce=true
    if part.Parent:FindFirstChild("Humanoid") then -- checking if the part is a child of the character
        player = game.Players:GetPlayerFromCharacter (part.Parent) -- find the player
        Tool = game.Workspace.LinkedSword:Clone()
        Tool.Parent = player.Backpack
    wait(5)--Change this to the time you want it to be
debounce=false
    end
end
end)

Ad

Answer this question