|
| 23 Jun 2013 12:43 PM |
Ok, So I made a TextButton. I want it to be whenever clicked, to teleport to a brick. Let's say I have a "YES" TextButton. When a player clicks it, It teleports to a brick.
GUI Image: https://twitter.com/alex_roblox/status/348857489619574784/photo/1 (When a player clicks "YES" it teleports to a brick)
This is an image of the invisible brick I want it to teleport to: https://twitter.com/alex_roblox/status/348857778984587264/photo/1 (It's name in Workspace is "Base")
Image of my script and properties of the "YES" TextButton: https://twitter.com/alex_roblox/status/348858150176313344/photo/1
My script so far:
function onClicked() if game.Players.LocalPlayer == nil then return end game.Players.LocalPlayer.Character.Torso.CFrame =CFrame.new(script.Parent.Parent.Base.Position) end script.Parent.MouseButton1Click:connect(onClicked)
May anyone fix this, please? |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 12:47 PM |
Bump. I need it for a game.
Thanks. |
|
|
| Report Abuse |
|
|
Merely
|
  |
| Joined: 07 Dec 2010 |
| Total Posts: 17266 |
|
|
| 23 Jun 2013 12:47 PM |
| My guess is script.Parent.Parent.Base does not exist. Try game.Workspace.Base |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 12:49 PM |
I will try that @Merely. Thanks. |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 12:50 PM |
If ^ doesn't work then it might be because the coordinates only look for 1 number. Try this
local x = script.Parent.Parent.Base.Position.X --Or what ever you route it to local y = script.Parent.Parent.Base.Position.Y local z = script.Parent.Parent.Base.Position.Z
function onClicked() if game.Players.LocalPlayer == nil then return end game.Players.LocalPlayer.Character.Torso.CFrame =CFrame.new(x, y, z) end script.Parent.MouseButton1Click:connect(onClicked) |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 12:52 PM |
Merely, It's not working.
I'm looking at the Output, it's printing:
13:53:47.844 - Players.Player1.PlayerGui.Info.Frame.TextButton.Script:3: bad argument #1 to 'new' (Vector3 expected, got userdata) 13:53:47.845 - Script "Players.Player1.PlayerGui.Info.Frame.TextButton.Script", Line 3 13:53:47.846 - stack end 13:53:47.846 - Disconnected event because of exception
I edited the script a bit: function onClicked() if game.Players.LocalPlayer == nil then return end game.Players.LocalPlayer.Character.Torso.CFrame =CFrame.new(game.Workspace.lolbrick)--This will Teleport You to anything Called Base end script.Parent.MouseButton1Click:connect(onClicked)
Still doesn't work. |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 12:54 PM |
@never, I'm trying that.
My positions are X: 1.574 Y: 57.944 Z: -15.5
Where should I place the number positions? |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 12:55 PM |
| Yea try what I said. Also, where is the brick you want to teleport the person to located? Workspace? |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 12:57 PM |
function onClicked() if game.Players.LocalPlayer == nil then return end game.Players.LocalPlayer.Character.Torso.CFrame =CFrame.new(1.5, 58, -15.5) end script.Parent.MouseButton1Click:connect(onClicked)
try that |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 12:58 PM |
| add another end after the first one too |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 12:58 PM |
Yes, it's in Workspace. I named the brick "lolbrick" (lolbrick is in Workspace, It's a single brick Part) |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 12:58 PM |
| just kidding didn't see the end at the if statement. I normally phrase mine differently, keep the amount of end's |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 12:58 PM |
function onClicked() if game.Players.LocalPlayer then game.Players.LocalPlayer.Character.Torso.CFrame=Workspace.Base.CFrame + Vector3.new(0, 2.5, 0) end end script.Parent.MouseButton1Click:connect(onClicked) |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 12:59 PM |
| If you put in the coordinates where they will teleport then you don't need a brick for the player to teleport to |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 01:01 PM |
| @never, Thanks so much! It works! |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 01:02 PM |
| @never It usually is better to do this just in case if he were to move the part somewhere else. Otherwise users that click the button would appear in the incorrect position. |
|
|
| Report Abuse |
|
|
|
| 23 Jun 2013 01:04 PM |
@levi, It's only 1 way. When clicked, it would either:
1) Teleport to the brick or 2) Teleport to the coordinates
I'm not moving the part anywhere else. It's just teleport to a coordinate. |
|
|
| Report Abuse |
|
|