mixter13
|
  |
| Joined: 12 Apr 2008 |
| Total Posts: 49 |
|
|
| 17 Oct 2011 08:57 PM |
I just wanna make a script to teleport me to a VIP room when a model called VIPTeleport is touched.
player = nil tele = game.Workspace.VIPTeleport.Torso target = Vector3.new(20, 663.2, -20) --...and this
function onTouch(part) --Set the value of "player" to the player's name player.Character.Torso.CFrame = target --teleport the player end
function fadeTo(a, b, c) for transparency = a, b, c do --go from a to b, counting by c
for _, part in pairs(player.Character:GetChildren()) do --for each of the objects in the character,
if part:IsA("BasePart") then --check if it's a part, and if so
part.Transparency = transparency --set its transparency end end wait(0.1) end end
fadeTo(0, 1, 0.1) --fade out, script.Parent.Touched:connect(onTouched) fadeTo(1, 0, -0.1) --fade back in
So far, that's what I've got. I only need help on setting the value of "player". |
|
|
| Report Abuse |
|
|
GoldenUrg
|
  |
| Joined: 23 Aug 2009 |
| Total Posts: 6428 |
|
|
| 17 Oct 2011 09:36 PM |
| player = Game.Players:GetPlayerFromCharacter(part.Parent) |
|
|
| Report Abuse |
|
|
|
| 17 Oct 2011 10:57 PM |
| make it Check for T-Shirt? |
|
|
| Report Abuse |
|
|
mixter13
|
  |
| Joined: 12 Apr 2008 |
| Total Posts: 49 |
|
|
| 18 Oct 2011 06:10 PM |
| I already have a vip door to the teleport brick. |
|
|
| Report Abuse |
|
|
mixter13
|
  |
| Joined: 12 Apr 2008 |
| Total Posts: 49 |
|
|
| 18 Oct 2011 06:12 PM |
| I also meant to set the player value to the player's name. |
|
|
| Report Abuse |
|
|
GoldenUrg
|
  |
| Joined: 23 Aug 2009 |
| Total Posts: 6428 |
|
|
| 18 Oct 2011 06:53 PM |
player.Character won't work if "player" is a name. You can get the player.Name or the character name (usually hit.Parent.Name).
|
|
|
| Report Abuse |
|
|
mixter13
|
  |
| Joined: 12 Apr 2008 |
| Total Posts: 49 |
|
|
| 18 Oct 2011 08:06 PM |
| Wait, how do I apply that? |
|
|
| Report Abuse |
|
|
GoldenUrg
|
  |
| Joined: 23 Aug 2009 |
| Total Posts: 6428 |
|
|
| 18 Oct 2011 08:18 PM |
function onTouch(part) --Set the value of "player" to the player of that part player = Game.Players:GetPlayerFromCharacter(part.Parent) if( player ) then player.Character.Torso.CFrame = target --teleport the player end end |
|
|
| Report Abuse |
|
|
mixter13
|
  |
| Joined: 12 Apr 2008 |
| Total Posts: 49 |
|
|
| 19 Oct 2011 06:08 PM |
Still doesn't work. The error:
Workspace.VIPTeleport.Torso.Script:17:attempt to index global 'player' (a nil value)
How do I fix this error at line 17? |
|
|
| Report Abuse |
|
|
mixter13
|
  |
| Joined: 12 Apr 2008 |
| Total Posts: 49 |
|
|
| 21 Oct 2011 06:24 PM |
bump, now I have a new script.
player = nil tele = game.Workspace.VIPTeleport.Torso target = Vector3.new(20, 663.2, -20) --...and this
function onTouch(part) if game.Players:findFirstChild(part.Parent.Name) then player = game.Players[part.Parent.Name] player.Character.Torso.CFrame = target --teleport the player end end
function fadeTo(a, b, c) for transparency = a, b, c do --go from a to b, counting by c
for _, part in pairs(player.Character:GetChildren()) do --for each of the objects in the character,
if part:IsA("BasePart") then --check if it's a part, and if so
part.Transparency = transparency --set its transparency end end wait(0.1) end end
fadeTo(0, 1, 0.1) --fade out, script.Parent.Touched:connect(onTouched) fadeTo(1, 0, -0.1) --fade back in
The error says that: Workspace.VIPTeleport.Torso.Script:16: attempt to index global 'player' (a nil value) |
|
|
| Report Abuse |
|
|