Line 22 is erroring with ‘WeaponValue is not a valid member of Folder “he4rtsformoonlight.leaderstats”’
local teleportPart = script.Parent
local locations = {}
local debounce = false
for i = 1, 9 do
local locationPart = game.Workspace.Locations:FindFirstChild("Location" .. i)
if locationPart then
table.insert(locations, locationPart)
end
end
if teleportPart then
teleportPart.Touched:Connect(function(hit)
if debounce then return end
debounce = true
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local locationPart = locations[math.random(1, #locations)]
player.Character.HumanoidRootPart.CFrame = locationPart.CFrame
game.Workspace.Sounds["bass.wav"]:Play()
local WeaponValue = hit.Parent.leaderstats:WaitForChild("Weapon")
local SwordsmanTool = game.ServerStorage.Weapons.Swordsman
if WeaponValue.Value == "Swordsman" then
local newSwordsmanTool = SwordsmanTool:Clone()
newSwordsmanTool.Parent = player.Backpack
end
end
wait(1)
debounce = false
end)
end
local teleportPart = script.Parent
local locations = {}
local debounce = false
for i = 1, 9 do
local locationPart = game.Workspace.Locations:FindFirstChild("Location" .. i)
if locationPart then
table.insert(locations, locationPart)
end
end
if teleportPart then
teleportPart.Touched:Connect(function(hit)
if debounce then return end
debounce = true
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local locationPart = locations[math.random(1, #locations)]
player.Character.HumanoidRootPart.CFrame = locationPart.CFrame
game.Workspace.Sounds["bass.wav"]:Play()
local WeaponValue = player.leaderstats:WaitForChild("Weapon")
local SwordsmanTool = game.ServerStorage.Weapons.Swordsman
if WeaponValue.Value == "Swordsman" then
local newSwordsmanTool = SwordsmanTool:Clone()
newSwordsmanTool.Parent = player.Backpack
end
end
wait(1)
debounce = false
end)
end