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

I MADE THIS TOUCH SCRIPT BUT ON ONE TOUCH IT GIVES 7 SWORDS ?

Asked by 10 years ago

part = script.Parent

serverstorage = game:GetService("ServerStorage")

part.Touched:connect(function(hit)

if game.Players:GetPlayerFromCharacter(hit.Parent) then

p = game.Players:GetPlayerFromCharacter(hit.Parent)

part.BrickColor = BrickColor.new("Really red")

local sword = serverstorage:WaitForChild("Sword"):Clone()

sword.Parent = p.Backpack

end

end)

0
THANKS SO MUCH :D DAVIDmindcraft 0 — 10y

2 answers

Log in to vote
0
Answered by
Discern 1007 Moderation Voter
10 years ago

Please remember to use the code block :)

About the script, check this out:

part = script.Parent
serverstorage = game:GetService("ServerStorage")
part.Touched:connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
p = game.Players:GetPlayerFromCharacter(hit.Parent)
part.BrickColor = BrickColor.new("Really red")
if not p.Backpack:findFirstChild("Sword") then --To check if the player already has a sword. If they don't then the script continues.
local sword = serverstorage:WaitForChild("Sword"):Clone()
sword.Parent = p.Backpack
end
end
end)
Ad
Log in to vote
0
Answered by 10 years ago

That is where Debounce comes in...

Answer this question