Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

1 comment

0

THANKS SO MUCH :D

2 answers

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.