Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
| |
|
janthran
|
  |
| Joined: 15 May 2009 |
| Total Posts: 17429 |
|
|
| 22 Dec 2013 09:28 PM |
| script.Parent.ClickDetector.MouseClick:connect(function(plr) print(plr) end) |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 22 Dec 2013 09:30 PM |
local torso = plr.Character.Torso
Would that be correct? or is it already in the chracter |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 22 Dec 2013 09:51 PM |
script.Parent.ClickDetector.MouseClick:connect(function(plr)
local torso = plr.Character.Torso if script.Parent.Parent.Press.pending == true then torso.CFrame = CFrame.new(60.258, 83.4, -263.102) end end)
This isn't outputting anything, or erroring.
I'm assuming I'm indexing wrong--do you have any ideas? |
|
|
| Report Abuse |
|
|
|
| 22 Dec 2013 09:56 PM |
"script.Parent.ClickDetector.MouseClick:connect(function(plr)"
Even though you defined plr, it won't be the player itself. It will be the brick that touched it. So you need something like:
script.Parent.ClickDetector.MouseClick:connect(function(part) if game.Players:findFirstChild(part.Parent) then local torso=part.Parent:findFirstChild("Torso") if script.Parent.Parent.Press.pending == true then torso.CFrame = CFrame.new(60.258, 83.4, -263.102) end end end) |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 22 Dec 2013 09:59 PM |
script.Parent.ClickDetector.MouseClick:connect(function(plr)
local torso = plr.Character.Torso print(plr) print(script.Parent.Parent.Press.pending.Value) if script.Parent.Parent.Press.pending == true then torso.CFrame = CFrame.new(60.258, 83.4, -263.102) end end)
prints the player and the value but doesn't teleport the player--should I not use .cframe for teleporting? |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 22 Dec 2013 10:04 PM |
Wrecker I think you may be onto something
however I got this error using your updated version
20:03:20.272 - Workspace.Boosta.button.Script:5: attempt to index global 'part' (a nil value)
line 5 if game.Players:findFirstChild(part.Parent) then
line 6
local torso=part.Parent:findFirstChild("Torso") |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
| |
|
|
| 22 Dec 2013 10:08 PM |
| That's because part is undefined, but will only get defined once something touches the brick. |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 22 Dec 2013 10:10 PM |
This is a click detector not a ontouched?
|
|
|
| Report Abuse |
|
|
|
| 22 Dec 2013 10:11 PM |
I mean clicked.
This part defines it (once clicked): "script.Parent.ClickDetector.MouseClick:connect(function(part)" |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 22 Dec 2013 10:14 PM |
It prints after it is clicked, so it should work but it doesn't. Full updated script:
script.Parent.ClickDetector.MouseClick:connect(function(plr)
print(plr) if game.Players:findFirstChild(part.Parent) then local torso=part.Parent:findFirstChild("Torso")
if script.Parent.Parent.Press.pending == true then torso.CFrame = CFrame.new(60.258, 83.4, -263.102) end end end) |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
| |
|
|
| 22 Dec 2013 10:17 PM |
Nevermind. I checked the wiki, I was wrong. It should be:
script.Parent.ClickDetector.MouseClick:connect(function(player) player.Character:WaitForChild("Torso") --waits until Torso exists (saftey measure) if script.Parent.Parent.Press.pending==true then player.Character.Torso.Position=CFrame.new(60.258, 83.4, -263.102) end end) |
|
|
| Report Abuse |
|
|
|
| 22 Dec 2013 10:19 PM |
| Your updated script should work too, but change part.Parent into plr for it to work. |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 22 Dec 2013 10:21 PM |
| Neither of them are working :/ |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 22 Dec 2013 10:30 PM |
| player.Character.Torso.CFrame=CFrame.new(60.258, 83.4, -263.102) |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 22 Dec 2013 10:40 PM |
that doesn't work either ill upload my thing as a model
http://www.roblox.com/script-help-item?id=139478541 |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 22 Dec 2013 10:44 PM |
"if script.Parent.Parent.Press.pending == true then " Should probably be "if script.Parent.Parent.Press.pending.Value == true then " if it's a boolvalue |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 22 Dec 2013 10:46 PM |
script.Parent.ClickDetector.MouseClick:connect(function(plr)
print(plr) if game.Players:findFirstChild(plr) then local torso=part.Parent:findFirstChild("Torso")
if script.Parent.Parent.Press.pending.Value == true then player.Character.Torso.CFrame=CFrame.new(60.258, 83.4, -263.102) end end end)
when I updated it to that it still fails to work
thank you for catching that though |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 22 Dec 2013 10:47 PM |
Stop adding random stuff... People are giving you the script.
script.Parent.ClickDetector.MouseClick:connect(function(plr) local torso=player.Character.Torso
if script.Parent.Parent.Press.pending.Value == true then player.Character.Torso.CFrame=CFrame.new(60.258, 83.4, -263.102) end
end) |
|
|
| Report Abuse |
|
|
wazap
|
  |
| Joined: 29 Jun 2007 |
| Total Posts: 23234 |
|
|
| 22 Dec 2013 10:48 PM |
print(plr) should be print(plr.Name)
and also
if game.Players:findFirstChild(plr.Name) then
plr is the PlayerObject though... No need to use game.Players:findFirstChild(plr) or anything... |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 22 Dec 2013 10:49 PM |
"print(plr) should be print(plr.Name)" No, not necessarily. Print tostrings() all its arguments |
|
|
| Report Abuse |
|
|
|
| 22 Dec 2013 10:50 PM |
This is what I came up with based on your model.
script.Parent.ClickDetector.MouseClick:connect(function(plr) if plr.Character:findFirstChild("Torso") and script.Parent.Parent:findFirstChild("Press").pending.Value==true then plr.Character.Torso.Position=CFrame.new(60.258, 83.4, -263.102) end end) |
|
|
| Report Abuse |
|
|