So this teleporting script is supposed to teleport a player to the game and give them their weapon and equip it.
The script works fine, but it tends to have this glitch where it will fling people out of the map. It's relatively common, and I don't know how to stop it besides adding invisible ceilings to the map.
Can someone please help me?
Here's the script:
local Player = script.Parent.Parent.Parent.Parent.Parent local Primary = game.ReplicatedStorage.Guns.Pistol:Clone() function onButtonClicked() if game.Workspace.Playing.Value == true then Player.CameraMode = "LockFirstPerson" Player.Backpack.Teled.Value = true local torso = Player.Character.Torso spawns = {} for i,v in ipairs(game.Workspace.Map.Spawns:GetChildren()) do if v.Name == "Spawn" then table.insert(spawns,v) end end torso.CFrame = spawns[math.random(1,#spawns)].CFrame + Vector3.new(0,4,0) Primary.Parent = Player.Backpack Player.Character.Humanoid:EquipTool(Player:WaitForChild("Backpack"):WaitForChild(Primary.Name)) script.Parent.Parent.Parent:remove() end end script.Parent.MouseButton1Click:connect(onButtonClicked)
Try this:
local spawn = spawns[math.random(1, #spawns)] spawn.CanCollide = false torso.CFrame = spawn.CFrame*CFrame.new(0, torso.Parent["Left Leg"].Size.Y, 0)
This would simply create the variable spawn to show the script what has been chosen as spawn and disable the spawn's collision. Then it would change the torso's CFrame to make the character stand on the spawn.
Hope this helped. :)