Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What did I do wrong in this script?

Ok, so I went on ROBLOX forums and all I got was people debating what method I use to actually teleport the player, so anyway, what I wanted to do was click a gui named KiritoButton which would take me to a spawn called KiritoSpawn. Here it is:

Player = game.Players.LocalPlayer
Spawn = game.Workspace.KiritoSpawn
TeleportButton = script.Parent.KiritoButton
HasPressedTeleport = false

function MouseEnterTeleportButton()
	TeleportButton.BackgroundColor3 = Color3.new(255,1,4)
	
end

function MouseLeftTeleportButton()
	TeleportButton.BackgroundColor3 = Color3.new(144,144,144)
	
end

function TeleportPlayer()
	if HasPressedTeleport == false then
		Player.Character:MoveTo(Spawn.Position)
	end
	
end

TeleportButton.MouseEnter:connect (MouseEnterTeleportButton)
TeleportButton.MouseLeave:connect (MouseLeftTeleportButton)
TeleportButton.MouseButton1Down:connect(TeleportPlayer) 

Any help would be greatly appreciated.

EDIT: 18:28:21.963 - Auto-Saving... 18:28:24.160 - Workplace is not a valid member of DataModel 18:28:24.161 - Script 'Players.Player.PlayerGui.LocalScript', Line 1 18:28:24.162 - Stack End 18:28:24.163 - KiritoButton is not a valid member of ScreenGui 18:28:24.164 - Script 'Players.Player.PlayerGui.KiritoButton.Script', Line 3 18:28:24.164 - Stack End

This is the output and it is a normal script.

EDIT 2: I tried using 'spawn' instead of 'Spawn' and nothing happened. I also tried (because the button has a decal on it) putting the script into the image and nothing happened. I even tried making it a local script and still nothing.

2 comments

0

There's nothing wrong with that script that I can see. You may want to consider telling us: What you expect, what actually happens instead, output, location and type of script, whether FilteringEnabled is toggled on

0

The output should be above now.

1 answer

for moving the player I would recommend CFrame rather than MoveTo.

5 comments

0

I tried substituting MoveTo with CFrame and nothing happened...

0

Heres an example: game.Players.LocalPlayer.Character.CFrame = CFrame.new(Vector3.new(0, 0, 0))

0

Is the 0,0,0 where I would put the co-ordinates of the spawn? Thank you.

0

yes

0

Still nothing, I'm afraid...

This discussion is preserved as it was. New answers, comments, and votes are closed.