So I have a game rn. And I have a lobby'ish place and I want it so that if the player clicks the block, then it'll teleport the player to a new part of the map. (Oh and I don't even know if the instance.new code is working.)
local firstSpawnFolder = game.workspace.FirstSpawnFolder local clickForSpawnPart = firstSpawnFolder.ClickForSpawnPart local clickDetector = clickForSpawnPart.ClickDetector clickDetector.MouseClick:Connect(function(hit) SamuraiSpawn = Instance.new("SpawnLocation",game.workspace) SpawnLocation.Position = (237.4,2.1,-176.5) SpawnLocation.Orientation = (0,110,0) game.workspace.Players.LocalPlayer("Humanoid").Position = Vector3.new(237.4,2.1,-176.5) end)
First of all, you don't need to create a SpawnLocation as this is client side. and spawning is done via the server. Even if this code was on the server and working, it would redundant to make a spawn location each time.
local FirstSpawnFolder = game.workspace:FindFirstChild("FirstSpawnFolder") local ClickDetector = FirstSpawnFolder:WaitForChild("ClickForSpawnPart"):WaitForChild("ClickDetector") ClickDetector.MouseClick:Connect(function() game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(237.4, 2.1, -176.5) end)
When teleporting a Character, you'll want to change their HRP's CFrame or else it will kill them.
The code above should work.