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: Assingn a player to a part, then they respawn on it?

Previous Thread :: Next Thread 
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
13 May 2014 08:29 PM
So far, this is what I have. It teleports them to a random block, but I need a way for them to respawn on it.

function Teleport()
Blks = Game.Workspace.Blocks:GetChildren()
for i,v in pairs (Game.Players:GetPlayers()) do
Name = v.Name
Blk1 = Game.Workspace:FindFirstChild(Name)
if Blk1 then
Blk2 = Blk1:FindFirstChild("Humanoid")
if Blk2 then
v.Character.Humanoid.WalkSpeed = 0
v.Character:MoveTo(Blks[i].Position)
wait(7)
v.Character.Humanoid.WalkSpeed = 16
end
end
end
end
Teleport()
Report Abuse
Prescience is not online. Prescience
Joined: 26 Apr 2014
Total Posts: 188
13 May 2014 08:30 PM
Make a Object Value inside the Player called 'Spawn' and set the value to the part they are supposed to spawn to. When they respawn just have them spawn to the value of that ObjectValue- hence the finished result.
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
13 May 2014 08:37 PM
What do you mean by "Have them spawn to the objectvalue", how will it even respawn them? I've already followed your steps. Here's what I did to set it to a part:

Spawn.Value = Blks[math.random(1,#Blks)] -- Blks is already a varaible in the new script.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
13 May 2014 08:38 PM
CharacerAdded event
MoveTo method (and just use the objectValue.Value.Position)
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
13 May 2014 08:40 PM
Here's what I put. It doesn't work though:


local Spawn = Instance.new("ObjectValue")
Spawn.Parent = v
Spawn.Name = "Spawn"
Spawn.Value = Blks[math.random(1,#Blks)]
Report Abuse
Prescience is not online. Prescience
Joined: 26 Apr 2014
Total Posts: 188
13 May 2014 08:42 PM
Okay so heres the idea,

PartsTab={Part1,Part2,Part3}

game.Players.PlayerAdded:connect(function(Player)

Player.CharacterAdded:connect(function(ch)

if Player:FindFirstChild'Spawn'==nil then
local sp=Instance.new('ObjectValue',Player)
sp.Name='Spawn' sp.Value=PartsTab[math.random(1,#PartsTab)]
elseif Player:FindFirstChild'Spawn'~=nil and Player.Spawn.Value~=nil then
ch.Torso.CFrame=Player.Spawn.Value.CFrame+CFrame.new(0,5,0)
elseif Player:FindFirstChild'Spawn'~=nil and Player.Spawn.Value==nil then
Player.Spawn.Value=PartsTab[math.random(1,#PartsTab)]
ch.Torso.CFrame=Player.Spawn.Value.CFrame+CFrame.new(0,5,0)
end

end)
end)


that should take care of you.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
13 May 2014 08:42 PM
Now you need to connect a characteradded event and actually move them
Report Abuse
Accomplishable is not online. Accomplishable
Joined: 13 Aug 2009
Total Posts: 6207
13 May 2014 08:49 PM
Workspace.Script:9: bad argument #2 to 'random' (interval is empty)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
14 May 2014 12:44 AM
That means argument2 is less than argument1 (or argument2 is 0)
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