So I was given this script that supposedly allows you to equip and unequip a sword once you are in a specific area but it hasn't been working. They said to put the sword tool in the starterpack and it would work but all it did was put it in my starter pack for the whole time instead of spawning it in a specific area and then removing it once you walked out of that area.
Here is the script:
local IsTouching = false
script.Parent.Touched:connect(function(hit)
local hum = hit.Parent:FindFirstChild('Humanoid')
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if hum and not IsTouching then
IsTouching = true
hit.Parent:FindFirstChild('Humanoid'):EquipTool(plr.Backpack.LinkedSword)
end
end)
script.Parent.TouchEnded:connect(function(hit)
local hum = hit.Parent.FindFirstChild('Humanoid')
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if hum and not IsTouching == false then
IsTouching = false
hit.Parent:FindFirstChild('Humanoid'):UnEquipTools()
end
end)
Please help me. :(

1 comment
Use a codeblock in the future https://forum.scriptinghelpers.org/topic/82/how-to-format-questions-answers-on-the-main-site