generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Need help with a Script

Previous Thread :: Next Thread 
alexrocks911 is not online. alexrocks911
Joined: 14 Feb 2012
Total Posts: 11546
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
alexrocks911 is not online. alexrocks911
Joined: 14 Feb 2012
Total Posts: 11546
23 Jun 2013 12:47 PM
Bump.
I need it for a game.


Thanks.
Report Abuse
Merely is not online. 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
alexrocks911 is not online. alexrocks911
Joined: 14 Feb 2012
Total Posts: 11546
23 Jun 2013 12:49 PM
I will try that @Merely.
Thanks.
Report Abuse
neverhammer is not online. neverhammer
Joined: 13 Sep 2009
Total Posts: 963
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
alexrocks911 is not online. alexrocks911
Joined: 14 Feb 2012
Total Posts: 11546
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
alexrocks911 is not online. alexrocks911
Joined: 14 Feb 2012
Total Posts: 11546
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
neverhammer is not online. neverhammer
Joined: 13 Sep 2009
Total Posts: 963
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
neverhammer is not online. neverhammer
Joined: 13 Sep 2009
Total Posts: 963
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
neverhammer is not online. neverhammer
Joined: 13 Sep 2009
Total Posts: 963
23 Jun 2013 12:58 PM
add another end after the first one too
Report Abuse
alexrocks911 is not online. alexrocks911
Joined: 14 Feb 2012
Total Posts: 11546
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
neverhammer is not online. neverhammer
Joined: 13 Sep 2009
Total Posts: 963
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
levi998234 is not online. levi998234
Joined: 28 Jul 2008
Total Posts: 53
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
neverhammer is not online. neverhammer
Joined: 13 Sep 2009
Total Posts: 963
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
alexrocks911 is not online. alexrocks911
Joined: 14 Feb 2012
Total Posts: 11546
23 Jun 2013 01:01 PM
@never, Thanks so much! It works!
Report Abuse
levi998234 is not online. levi998234
Joined: 28 Jul 2008
Total Posts: 53
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
alexrocks911 is not online. alexrocks911
Joined: 14 Feb 2012
Total Posts: 11546
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image