Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesn't this teleport gui work?

Asked by 8 years ago

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

Log in to vote
0
Answered by 8 years ago

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()

0
How would I write line 3 with :WaitForChild() in it? harleyb09 5 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

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

0
Tried it, didn't work... harleyb09 5 — 8y

Answer this question