I have a teleportation localscript that teleports the player to a part of the map when a GUI is clicked..
It works perfectly in studio, but in play mode it doesn't work, saying that it's attempting to index a nil value (character)
I don't really know what the problem is, because I can't WaitForChild() the character.
The localscript inside of a gui
player = game.Players.LocalPlayer character = player.Character human = character:WaitForChild("Humanoid") if not character or not character.Parent then character = player.CharacterAdded:wait() end character = game.Players.LocalPlayer.Character Sparkles = Instance.new("ParticleEmitter") script.Parent.MouseButton1Down:connect(function(bloop) Sparkles.Rate = 50 Sparkles.Parent = character.Torso wait(2) character.Torso.CFrame = CFrame.new(Vector3.new(-14, 9.5, 28.4)) Sparkles.Enabled = false human.WalkSpeed = 25 script.Parent.Visible = false script.Parent.Parent.Spawn.Visible = true end)
I think you're overcomplicating things, this is how I would do it.
local tppart = game.Workspace.teleport function onClick() script.Parent.Parent.Parent.Character.Torso.CFrame = CFrame.new(tppart.Position.x, tppart.Position.y+3, tppart.Position.z) script.Parent.Visible = false end script.Parent.MouseButton1Click(onClick) --depends on how many parents you have