|
function onButtonClicked()
p = script.Parent.Parent.Parent.Parent.Playername.Character
t = p:findFirstChild("Torso")
t.Position = Position+Vector3.new(0, 40, 0)
end
script.Parent.MouseButton1Click:connect(onButtonClicked)
Output says "Playername is not a valid member of Player." So, what would I put there? |
|
|
You would put the name of the player there...
If the gui an ancestor of the Player instance you dont even need the players name, you can do something like
player = script.Parent
while player.className ~= "Player" do
player = player.Parent
end
and hten player will equal the player. |
|
|
Would that work for everybody in a server or just for the person named "Player?" |
|
shoukstaJoin Date: 2009-12-01 Post Count: 1906 |
Use this in a LocalScript
function onButtonClicked()
p = game.Players.LocalPlayer.Character
t = p:findFirstChild("Torso")
t.Position = Position+Vector3.new(0, 40, 0)
end
script.Parent.MouseButton1Click:connect(onButtonClicked) |
|
|
@Newt
That would work for the player that clicks the GUI button. (The local player)
If you want this to happen for every player in teh server you need to use a table of the player service and a for loop.
e.g.
P = game.Players:GetChildren()
for i=1, #p do
p[i].Character.Torso.CFrame = CFrame.new(x, y, z)
end
|
|
|
@shouksta
Output says for line 4 "Bad Argument for "?" (Vector3 expected, got nil)" |
|
|
Mm. Position isnt defined. (Which is what nil means, "Doesnt exist")
Position of what? |
|
|
Position of the user's torso. |
|
shoukstaJoin Date: 2009-12-01 Post Count: 1906 |
sorry i shouldn't expect position to be defined >.> use this
function onButtonClicked()
p = game.Players.LocalPlayer.Character
t = p:findFirstChild("Torso")
t.Position = t.Position+Vector3.new(0, 40, 0)
end
script.Parent.MouseButton1Click:connect(onButtonClicked) |
|
|
Oh yeah, I totally forgot about that too. |
|
|
Wow... I feel stupid. How would I teleport a whole body? Right now it just teleports the torso and kills me. |
|
shoukstaJoin Date: 2009-12-01 Post Count: 1906 |
Sorry i'm the one being stupid didn't realise you were moving the torso
function onButtonClicked()
p = game.Players.LocalPlayer.Character
t = p:findFirstChild("Torso")
t.CFrame = t.CFrame+Vector3.new(0, 40, 0)
end
script.Parent.MouseButton1Click:connect(onButtonClicked) |
|
|
Yeah! I finally got my elevator working! To building helpers now! JK. |
|