|
| 26 Aug 2012 09:35 AM |
| How would I make a leaderboard that records obby stages when you step on a button and when you die you spawn on the button you stepped on last? |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2012 09:59 AM |
I just made this script and haven't tested it. If it doesn't work, tell me what the output says.
How to use: 1) Insert this script (the whole thing) into workspace 2) Make a model in workspace called "Checkpoints" 3) Insert all the checkpoint spawns into this model 4) Name each checkpoint spawn in the order they go. (The first one should be named "1" (no quotes), the second "2", third, "3", 27th "27" etc) 5) hope it works.
game.Players.PlayerAdded:connect(function(np) local stats = Instance.new("IntValue", np) stats.Name = "leaderstats" local stage = Instance.new("IntValue", stats) stage.Name = "Stage" np.CharacterAdded:connect(function(nc) local player = game.Players:GetPlayerFromCharacter(nc) if nc:findFirstChild("Torso") ~= nil then local checkpoint = workspace.Checkpoints[game.Players:GetPlayerFromCharacter(nc).leaderstats.Stage.Value] nc.Torso.CFrame = checkpoint.CFrame + Vector3.new(0, checkpoint.Size.y / 2 + 3, 0) end end) end) for _, v in pairs(workspace.Checkpoints:GetChildren()) do v.Touched:connect(function(h) if h.Parent:findFirstChild("Humanoid") ~= nil then local player = game.Players:GetPlayerFromCharacter(h.Parent) if player ~= nil then player.leaderstats.Stage.Value = v.Name end end end) end |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2012 10:02 AM |
droid pointed out something stupid on steam, here's a revised version (still untested)
game.Players.PlayerAdded:connect(function(np) local stats = Instance.new("IntValue", np) stats.Name = "leaderstats" local stage = Instance.new("IntValue", stats) stage.Name = "Stage" np.CharacterAdded:connect(function(nc) if nc:findFirstChild("Torso") ~= nil then local checkpoint = workspace.Checkpoints[np.leaderstats.Stage.Value] nc.Torso.CFrame = checkpoint.CFrame + Vector3.new(0, checkpoint.Size.y / 2 + 3, 0) end end) end) for _, v in pairs(workspace.Checkpoints:GetChildren()) do v.Touched:connect(function(h) if h.Parent:findFirstChild("Humanoid") ~= nil then local player = game.Players:GetPlayerFromCharacter(h.Parent) if player ~= nil then player.leaderstats.Stage.Value = v.Name end end end) end |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2012 10:03 AM |
| Do I put this in the brick? |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2012 10:06 AM |
*-.-
i gave you step-by-step instructions. and i quote:
"1) Insert this script (the whole thing) into workspace 2) Make a model in workspace called "Checkpoints" 3) Insert all the checkpoint spawns into this model 4) Name each checkpoint spawn in the order they go. (The first one should be named "1" (no quotes), the second "2", third, "3", 27th "27" etc) 5) hope it works." |
|
|
| Report Abuse |
|
|
| |
|
|
| 26 Aug 2012 10:15 AM |
| Well I don't have any comeback for that. |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2012 10:15 AM |
| The thing is idk how to view the output. |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2012 10:20 AM |
The script works fine, I just tested it. I added a small modification to make you start at stage 1 instead of stage 0 though:
game.Players.PlayerAdded:connect(function(np) local stats = Instance.new("IntValue", np) stats.Name = "leaderstats" local stage = Instance.new("IntValue", stats) stage.Name = "Stage" stage.Value = 1 np.CharacterAdded:connect(function(nc) if nc:findFirstChild("Torso") ~= nil then local checkpoint = workspace.Checkpoints[np.leaderstats.Stage.Value] nc.Torso.CFrame = checkpoint.CFrame + Vector3.new(0, checkpoint.Size.y / 2 + 3, 0) end end) end) for _, v in pairs(workspace.Checkpoints:GetChildren()) do v.Touched:connect(function(h) if h.Parent:findFirstChild("Humanoid") ~= nil then local player = game.Players:GetPlayerFromCharacter(h.Parent) if player ~= nil then player.leaderstats.Stage.Value = v.Name end end end) end |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2012 10:31 AM |
| How do I make it so that I spawn at the stage? |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2012 10:32 AM |
you should spawn there automagically
i didnt test that part tho, actually |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2012 10:34 AM |
I tested it and it didn't work. (I don't have any spawnlocations other than the default one where you spawn in the middle.) |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2012 10:35 AM |
so now go tell me the output
"but i don't know how to open the output"
go google it |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2012 10:38 AM |
11:37:47 - Touched is not a valid member of Script 11:37:47 - Script "Workspace.Checkpoints.Script", Line 15 11:37:47 - stack end |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2012 10:39 AM |
...
step 1: Insert the script into workspace |
|
|
| Report Abuse |
|
|
|
| 26 Aug 2012 10:46 AM |
| OK and it still doesn't spawn. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 26 Aug 2012 07:06 PM |
| Please help me! I need to know how to make the person spawn at the brick. |
|
|
| Report Abuse |
|
|
| |
|