Teleporting Ingame

I have a script that I would like to revist. I don’t want it to kill the player but instead to teleport it to a spesifc postion. I can’t find anything like that online though.

Questions

Can you move a players position?

How can you do that?

Script

local part = script.Parent
local deb = false
local gamepass1 = 18141166
local gamepass2 = 18141180
local marketplaceService = game:GetService('MarketplaceService')
--- Gamepass 1 is wins
--- Gamepass 2 is coins
local debtime = 1



part.Touched:Connect(function(hit)
	local touchPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)

	if not touchPlayer or deb then return end
	local textLabel = touchPlayer.PlayerGui.Winnerpartthing.Level1

	deb = true
	if marketplaceService:UserOwnsGamePassAsync(touchPlayer.UserId, gamepass1) and marketplaceService:UserOwnsGamePassAsync(touchPlayer.UserId, gamepass2) then
		hit.Parent:FindFirstChild('Humanoid').Health = 0
		touchPlayer.leaderstats.Wins.Value += 2
		touchPlayer.leaderstats.Coins.Value += 100
		textLabel.Text = "Congrats on beating Level 1. You Have earned some rewards!"
		textLabel.Visible = true
		wait(4)
		textLabel.Visible = false
		wait(debtime)
		deb = false
	elseif marketplaceService:UserOwnsGamePassAsync(touchPlayer.UserId, gamepass1)then
		hit.Parent:FindFirstChild('Humanoid').Health = 0
		touchPlayer.leaderstats.Wins.Value += 2
		touchPlayer.leaderstats.Coins.Value += 50
		textLabel.Text = "Congrats on beating Level 1. You Have earned some rewards!"
		textLabel.Visible = true
		wait(4)
		textLabel.Visible = false
		wait(debtime)
		deb = false
	elseif marketplaceService:UserOwnsGamePassAsync(touchPlayer.UserId, gamepass2) then
		hit.Parent:FindFirstChild('Humanoid').Health = 0
		touchPlayer.leaderstats.Wins.Value += 1
		touchPlayer.leaderstats.Coins.Value += 100
		textLabel.Text = "Congrats on beating Level 1. You Have earned some rewards!"
		textLabel.Visible = true
		wait(4)
		textLabel.Visible = false
		wait(debtime)
		deb = false
	else
		hit.Parent:FindFirstChild('Humanoid').Health = 0
		touchPlayer.leaderstats.Wins.Value += 1
		touchPlayer.leaderstats.Coins.Value += 50
		textLabel.Text = "Congrats on beating Level 1. You Have earned some rewards!"
		textLabel.Visible = true
		wait(4)
		textLabel.Visible = false
		wait(debtime)
		deb = false
	end

end)


2 Likes

Just use the HumanoidRootPart.Position or HumanoidRootPart.CFrame. The HumanoidRootPart is a descendant of the Player’s Character, btw.

How would I use this?

Also unrealited to this script I have a problem in my game with spawns so could I do like a function where when they join they go to a position using.

1 Like

For teleporting just use Character.HumanoidRootPart.CFrame = teleporter.CFrame and done.

Client:

game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = workspace.TeleportPart.CFrame -- make a part name that to teleport part and change cancollide = false anchored = true and transparent if u dont want players to see it

Server:

game.Players.PlayerAdded:Connect(function(player)
    player.Character.CFrame = workspace.TeleportPart.CFrame
end)
1 Like

I would make this a part then…

Yeah. it should be a part. it should be anchored and can collide off, and if u dont want the players to see it make it transparent

1 Like

Thanks

@BluestOfFlames and @anirudh851 and @octav20071

Wish I could give you all solution

1 Like

No problem! If anything breaks feel free to DM/ping

1 Like