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

What did I do wrong in this script?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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.

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 User#6546 35 — 9y
0
The output should be above now. harleyb09 5 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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

0
I tried substituting MoveTo with CFrame and nothing happened... harleyb09 5 — 9y
0
Heres an example: game.Players.LocalPlayer.Character.CFrame = CFrame.new(Vector3.new(0, 0, 0)) TacticalSutherland 20 — 9y
0
Is the 0,0,0 where I would put the co-ordinates of the spawn? Thank you. harleyb09 5 — 9y
0
yes TacticalSutherland 20 — 9y
0
Still nothing, I'm afraid... harleyb09 5 — 9y
Ad

Answer this question