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 » Scripters
Home Search
 

Re: No errors, but this should work?

Previous Thread :: Next Thread 
Jaitix is not online. Jaitix
Joined: 03 May 2014
Total Posts: 17724
21 Jul 2016 10:32 PM
-- Why isn't this working? I had it for a part if it touched it, it would teleport them to the part's location. But it doesn't work for a -- TextButton? Help!


local destinationBrick = game.Workspace.Spawn:FindFirstChild(script.TeleportTo.Value)

game.Workspace.BackWall.Back.Frame.TeleportBack.MouseButton1Click:connect(function(otherPart)
if otherPart and otherPart.Parent and otherPart.Parent:FindFirstChild('Humanoid') then
otherPart.Parent:MoveTo(destinationBrick.Position)
end
end)


-- Thanks if you can help!
Report Abuse
Jaitix is not online. Jaitix
Joined: 03 May 2014
Total Posts: 17724
21 Jul 2016 10:33 PM
The "--" are just me trying to make sure you guys know that me explaining the situation isn't part of the code.
Report Abuse
PerilousDanger is not online. PerilousDanger
Joined: 21 Aug 2012
Total Posts: 3773
21 Jul 2016 10:37 PM
If it's a surfaceGui it has to be in StarterGui
Report Abuse
Jaitix is not online. Jaitix
Joined: 03 May 2014
Total Posts: 17724
21 Jul 2016 10:40 PM
I don't think so, because all my other buttons change visibility and other properties but are still under the Model.


And if it did, then it'd give me an error, right?
Report Abuse
golfercab is not online. golfercab
Joined: 26 Sep 2011
Total Posts: 714
21 Jul 2016 10:42 PM
The problem might be this:

if otherPart and otherPart.Parent and otherPart.Parent:FindFirstChild('Humanoid') then

the otherPart, since it is a click event, is game.Players.(player name),

the if statement currently is something I would use for a touched event, and otherPart.Parent would be the model in workspace

you need to add .Character before :FindFirstChild("Humanoid")

if otherPart and otherPart.Parent and otherPart.Parent.Character and otherPart.Parent.Character:FindFirstChild('Humanoid') then
Report Abuse
Jaitix is not online. Jaitix
Joined: 03 May 2014
Total Posts: 17724
21 Jul 2016 10:47 PM
Still didn't work and no error still... Weird.



Report Abuse
PerilousDanger is not online. PerilousDanger
Joined: 21 Aug 2012
Total Posts: 3773
21 Jul 2016 10:48 PM
SurfaceGuis in Workspace can not detect when a user clicks them.

Parent them to StarterGui and set the 'Adornee' to the part, it'll look the same
Report Abuse
Jaitix is not online. Jaitix
Joined: 03 May 2014
Total Posts: 17724
21 Jul 2016 10:48 PM
The bottom two lines you just provided me, I switch the


if otherPart and otherPart.Parent and otherPart.Parent:FindFirstChild('Humanoid') then


with your code?


That's what I did.
Report Abuse
Jaitix is not online. Jaitix
Joined: 03 May 2014
Total Posts: 17724
21 Jul 2016 10:50 PM
I still feel like their is a way to do it in workspace as it works for my other Gui's.


But I don't even see an Adornee Property?
Report Abuse
golfercab is not online. golfercab
Joined: 26 Sep 2011
Total Posts: 714
22 Jul 2016 01:46 AM
yeah thats what I wanted. This may help you more than anything. If you don't know what the parameter is referencing, or if you want to see what lines of code are even running, put print() in several places print(1) print(2) print(3). Notice a print inside a if then statement isnt running? something isnt true or false and is not running the code inside of it. The problem has then become narrowed down. Also, if you are not sure what this otherPart even is? print(otherPart.Name) print(otherPart.Parent.Name) that should help you figure out what is going on. This will also help in a lot of bug fixes you might have to do in the future, its hard to write code that is bug free, I even see masters at scripting still use prints to see what is going on.

btw, I must of not of been thinking when I gave the lines of code earlier, because I was trying to say that otherPart is the player, that means otherPart.parent should be game.Players, which means, just remove the parent from the code I gave you.


if otherPart and otherPart.Character and otherPart.Character:FindFirstChild('Humanoid') then
Report Abuse
ComedicGesture is not online. ComedicGesture
Joined: 20 May 2011
Total Posts: 912
22 Jul 2016 03:11 AM
Values don't have any position. You defined destinationBrick as something.something.Value and then you did destinationBrick.Position. Last time I checked (unless value is the name of a part) you cannot port to a value.


im not a jerk but homie u 5
Report Abuse
pullman45 is not online. pullman45
Joined: 09 Jul 2012
Total Posts: 2891
22 Jul 2016 07:31 AM
When I tried MouseButton1Click, I got nowhere. When I tried MouseButton1Down, I got somewhere.

It could just be me but there's no harm in trying MouseButton1Down.
Report Abuse
Jaitix is not online. Jaitix
Joined: 03 May 2014
Total Posts: 17724
22 Jul 2016 09:31 AM
Okay, I just fixed the otherpart, and switched MouseButton1Click with MouseButton1Down and it gave me an error.


Workspace.BackWall.Back.Frame.TeleportBack.Script:4: attempt to index local 'otherPart' (a number value)


By the way, it teleports to the part in the stringvalue.
Report Abuse
golfercab is not online. golfercab
Joined: 26 Sep 2011
Total Posts: 714
22 Jul 2016 11:53 AM
btw, i think moveto sets the humanoid to walk to the position. I recommend CFrameing the torso

game.Players.(player name).Character.Humanoid.Torso.CFrame = CFrame.new(destinationBrick.Position)
Report Abuse
ComedicGesture is not online. ComedicGesture
Joined: 20 May 2011
Total Posts: 912
22 Jul 2016 02:16 PM
idk why but nowadays when i try to actually help people they make me feel like im trolling or something. is what im saying really that stupid???


im not a jerk but homie u 5
Report Abuse
golfercab is not online. golfercab
Joined: 26 Sep 2011
Total Posts: 714
22 Jul 2016 02:19 PM
@comedicGesture sometimes I get that feeling too =p idk why
Report Abuse
Jaitix is not online. Jaitix
Joined: 03 May 2014
Total Posts: 17724
22 Jul 2016 02:40 PM
Sorry I am making you feel like you are "trolling", sometimes when I am replying, someone (might be you) has posted but since I am currently replying and my thread hasn't been updated to me, I am only replying to the people I see on the thread.


Anyways, I think I'll use a vector3 instead of using parts.
Report Abuse
Jaitix is not online. Jaitix
Joined: 03 May 2014
Total Posts: 17724
22 Jul 2016 02:44 PM
Oh, I understand the second line more now. The otherPart doesn't have player properties or events, therefore it can't get this.


But my original script was:

local destinationBrick = game.Workspace:FindFirstChild(script.TeleportTo.Value)

script.Parent.Touched:connect(function(otherPart)
if otherPart and otherPart.Parent and otherPart.Parent:FindFirstChild('Humanoid') then
otherPart.Parent:MoveTo(destinationBrick.Position)
end
end)


-- Now my script is:

destinationBrick = Vector3.new(29.184, 22.2, 35.262)

game.Workspace.BackWall.Back.Frame.TeleportBack.MouseButton1Down:connect(function(otherPart)
if otherPart and otherPart.Character and otherPart.Character:FindFirstChild('Humanoid') then
otherPart.Parent:MoveTo(destinationBrick)
end
end)

Report Abuse
golfercab is not online. golfercab
Joined: 26 Sep 2011
Total Posts: 714
22 Jul 2016 03:43 PM
neat, for the new script this line needs to be changed

otherPart.Parent:MoveTo(destinationBrick)

to

otherPart.Character:MoveTo(destinationBrick)

cause you cant move game.PlayerGuis to a place

i think, idk much about MoveTo

doing otherPart.Character.Humanoid:MoveTo(destinationBrick)

makes the humanoid walk to the position unless they tap wasd i think

I still recommend CFraming the Torso
Report Abuse
Jaitix is not online. Jaitix
Joined: 03 May 2014
Total Posts: 17724
22 Jul 2016 07:12 PM
Help!
Report Abuse
golfercab is not online. golfercab
Joined: 26 Sep 2011
Total Posts: 714
22 Jul 2016 07:42 PM
Is this an image button in a surfacegui or does this block have a clickdetector, if its using click detection do part.ClickDetector.MouseClick:connect()
Report Abuse
golfercab is not online. golfercab
Joined: 26 Sep 2011
Total Posts: 714
22 Jul 2016 07:45 PM
if it is a text button in a surface gui read this article on the wiki, the section about surfaceguis to understand how to allow them to detect player clicks

http://wiki.roblox.com/index.php?title=The_Fundamentals_of_Scripting_with_GUIs
Report Abuse
Jaitix is not online. Jaitix
Joined: 03 May 2014
Total Posts: 17724
22 Jul 2016 07:54 PM
I read that, and it's a TextButton.
Here is what I have now:


local destinationBrick = Vector3.new(29.184, 22.2, 35.262)
local TeleportBack = game.Workspace.BackWall.Back.Frame.TeleportBack
local player = game.Players.LocalPlayer
TeleportBack.MouseButton1Down:connect(function(otherPart)
if player:FindFirstChild('Humanoid') then
player:MoveTo(destinationBrick)
end
end)


-- The error message I get is:

Workspace.BackWall.Back.Frame.TeleportBack.Script:5: attempt to index upvalue 'player' (a nil value)
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
22 Jul 2016 07:56 PM
--script inside model of the teleport parts

local model = script.Parent
local part1 = model.Part1
local part2 = model.Part2

part1.Touched:connect(function(hit)
local human = hit.Parent:FindFirstChild('Humanoid')
if human then
human.Parent:MoveTo(part2.Position + Vector3.new(0,1,0))
end
end)

part2.Touched:connect(function(hit)
local human = hit.Parent:FindFirstChild('Humanoid')
if human then
human.Parent:MoveTo(part1.Position + Vector3.new(0,1,0))
end
end)


Report Abuse
Jaitix is not online. Jaitix
Joined: 03 May 2014
Total Posts: 17724
22 Jul 2016 07:58 PM
Time, it's a TextButton, not a part.
Mind if you can change it so it could work with a TextButton?


( I am bad with local stuff, so, sorry.)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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