This teleport script that work normally in studio, but doesn't work at all in a server. Can someone fix this for me ?
local mapIns = "map" .. script.Parent.Parent.mapID.Value
local spawnL = workspace[mapIns].spawn
local hitRequired = script.Parent.Parent.hitReq.Value
script.Parent.Touched:connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local notice = player.PlayerGui.notice.text
local playerstats = player.leaderstats
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") and playerstats.Hits.Value >= hitRequired then
hit.Parent.HumanoidRootPart.CFrame = CFrame.new(spawnL.Position)
elseif playerstats.Hits.Value < hitRequired then
notice.Text = "You need " .. hitRequired .. " hits or more to enter this!"
notice.Visible = true
wait(3.5)
notice.Visible = false
end
end)

1 comment
It worked correctly now. Thanks!