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

Why doesn't this teleport gui work?

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
		game.Players.LocalPlayer.Character.CFrame = CFrame.new(Vector3.new(-15,0.6,17))
end

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

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. 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.

I also tried using CFrame and that didn't work either, but I really want to know what I did wrong. Thank you.

2 answers

What this error means >.> 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 is that the location of 'KiritoButton' is not correct. If that is where the button really is try using :WaitForChild()

1 comment

0

How would I write line 3 with :WaitForChild() in it?

Assuming that the spawn actually exists you might want to try this:

Player = game.Players.LocalPlayer
spawn = game.Workspace:WaitForChild("KiritoSpawn")
TeleportButton = script.Parent:WaitForChild("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
     		   game.Players.LocalPlayer.Character.CFrame = CFrame.new(Vector3.new(-15,0.6,17))
	end
end

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

You also forgot a end near TeleportPlayer function :P

1 comment

0

Tried it, didn't work...

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