Game script apparently doesn't teleport players into locations

Hello Everyone!

So, I was trying to replicate Flee the Facility (I’ll obviously won’t release the game, I was just wondering how could I make a game similar to that, so I gave it a go) and I was going well until
I came to this:

So, basically, the game doesn’t teleport players into the map nor the beast location. I remember that it worked at the beginning, and for some reason it just stopped after I made the crawling script.

Here, take a look at my ServerScript!

local maps = game.ServerStorage.Maps
local status = game.ReplicatedStorage:WaitForChild("Status")
local avaiableMaps = maps:GetChildren()

local function GetCreator(map)
	if map:FindFirstChild("Creator") then
		return map:FindFirstChild("Creator").Value
	end
end

local function PrepareMap()
	local random = math.random(1, #maps:GetChildren())

	clonedMap = avaiableMaps[random]:Clone()
	clonedMap.Parent = workspace
end

local function TeleportPlayers()

	for i, v in pairs(game.Players:GetPlayers()) do
		if clonedMap:FindFirstChild("PlayerSpawns") then
			if v:FindFirstChild("Beast") then
				v.Character.PrimaryPart.Position = workspace.ChosenAsBeastPlace.BeastSpawn.Position
			else
				local randomSpawn = math.random(1, #clonedMap:FindFirstChild("PlayerSpawns"):GetChildren())
				v.Character.PrimaryPart.Position = clonedMap:FindFirstChild("PlayerSpawns"):GetChildren()[randomSpawn].Position + Vector3.new(0, 2, 0)
			end
			
		end
	end
end

local function ChooseBeast()
	local players = game.Players:GetPlayers()
	local randomPlayer = math.random(1, #players)
	
	local chosenPlayer = players[randomPlayer]
	local beastTag = Instance.new("IntValue")
	beastTag.Name = "Beast"
	beastTag.Parent = chosenPlayer
end

local function AddTag()
	for i, player in pairs(game.Players:GetPlayers()) do
		if not player:FindFirstChild("Beast") then
			local tag = Instance.new("IntValue")
			tag.Name = "Playing"
			tag.Parent = player
		end	
	end
end

local function RemoveTag()
	for i, player in pairs(game.Players:GetPlayers()) do
		if player:FindFirstChild("Playing") then
			player:FindFirstChild("Playing"):Destroy()
		end
	end
end

local function TeleportBeast()
	for i, plr in pairs(game.Players:GetPlayers()) do
		if plr:FindFirstChild("Beast") then
			if clonedMap:FindFirstChild("BeastSpawn") then
				plr.Character.PrimaryPart.Position = clonedMap:FindFirstChild("BeastSpawn").Position
				if plr.Character:FindFirstChild("CrawlScript") then
					plr.Character:FindFirstChild("CrawlScript").Disabled = true
				end
			end
		end
	end
end

-- Game Loop

while true do
	for i=15, 1, -1 do
		status.Value = "Intermission: "..i.." second(s) left!"
		wait(1)
	end
	ChooseBeast()
	PrepareMap()
	if clonedMap.Name then
		status.Value = "Chosen map: "..clonedMap.Name.." by "..GetCreator(clonedMap)
	end
	wait(3)
	AddTag()
	TeleportPlayers()
	for x=10, 1, -1 do
		status.Value = x.." second(s) Head Start!"
		wait(1)
	end
	
	TeleportBeast()
	for y=120, 1, -1 do
		status.Value = "Round in progress: "..y
		wait(1)
	end
	
	status.Value = "Round over!"
	
	for i, v in pairs(game.Players:GetPlayers()) do
		if v:FindFirstChild("Playing") or v:FindFirstChild("Beast") then
			v:LoadCharacter()
		end
	end
	
end

Also, here’s the crawling script, if this helps.

local player = script.Parent
local humanoid = player.Humanoid
local animation = humanoid:LoadAnimation(script:WaitForChild("AnimationR6"))

local UserInputService = game:GetService("UserInputService")

local crawling = false

humanoid.Running:Connect(function(speed)
	if speed > 0 then
		animation:AdjustSpeed(1)
	else
		animation:AdjustSpeed(0)
	end
end)


UserInputService.InputBegan:Connect(function(input, isTyping)
	if not isTyping then
		if input.KeyCode == Enum.KeyCode.LeftControl then
			if not crawling then
				crawling = true
				animation:Play()
				animation:AdjustSpeed(0)
				humanoid.WalkSpeed = 8
				humanoid.JumpPower = 0
				humanoid.HipHeight = -0.3
			else
				animation:Stop()
				humanoid.WalkSpeed = 16
				humanoid.JumpPower = 50
				humanoid.HipHeight = 0
				wait(0.1)
				crawling = false
			end
		end
	end
end)

I honestly don’t know why did this happen, can you help me out?

You should use :MoveTo instead of just teleporting the PrimaryPart. Just simply do this plr.character:MoveTo(Position)

Hmm, ok. I’ll try it out real quick.

Yep, I’ve tried it out and it teleports players perfectly, thanks!

1 Like