Advertisement
unknownexploits

aaa

Sep 1st, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. repeat wait() until script.Parent.main_script
  2.  
  3. local remoteEvent = Instance.new("RemoteEvent", game.Workspace)
  4. local serverFunctions = {}
  5.  
  6. function serverFunctions.spawnCustom(player)
  7. print(player)
  8. game.Workspace:WaitForChild(player.Name)
  9. game.Workspace[player.Name]:WaitForChild("Humanoid")
  10. local OldCharacter = player.Character
  11. local OldCharacterLocation = OldCharacter.Torso.Position
  12. local NewCharacter = game.ServerStorage.NewCharacter:Clone()
  13. NewCharacter.Name = player.Name
  14. NewCharacter.Torso.g.t.Text=player.Name
  15. NewCharacter.Torso.BrickColor = BrickColor.Random()
  16. NewCharacter.Parent = game.Workspace
  17.  
  18. local Humanoid = OldCharacter.Humanoid
  19. player.Character = NewCharacter
  20. Humanoid.Parent = NewCharacter
  21. Humanoid.PlatformStand = true
  22. OldCharacter:Destroy()
  23. local SpawnGui = player.PlayerGui:FindFirstChild("SpawnGui")
  24. if SpawnGui ~= nil then
  25. SpawnGui:Destroy()
  26. end
  27.  
  28. NewCharacter:MoveTo(workspace.spawnpoint.Position+Vector3.new(0,-5,0))
  29.  
  30. for i,v in pairs(workspace.Map.Checkpoints:GetChildren()) do
  31. v.Touched:Connect(function(h)
  32. if h.Name == "Head" then
  33. local calc = v['value'].Value;
  34. local lastCheckpoint = calc;
  35. if calc > lastCheckpoint then
  36. print("new checkpoint reached: "..calc);
  37. local lastCheckpoint = calc;
  38. end
  39. end
  40. end)
  41. end
  42.  
  43. while 1 do
  44. for i,v in pairs(workspace.Map.Checkpoints:GetChildren()) do
  45. local checks = v;
  46. local dist = (NewCharacter['Torso'].Position - checks.Position).magnitude;
  47. if dist < 8 then
  48. local calc = v['value'].Value;
  49. local lastCheckpoint = calc;
  50. if calc > lastCheckpoint then
  51. print("new checkpoint reached: "..calc);
  52. lastCheckpoint = calc;
  53. end
  54. end
  55. end
  56. wait();
  57. end
  58.  
  59. workspace.finish.Touched:Connect(function(hit)
  60. hit.Parent:MoveTo(workspace.spawnpoint.Position+Vector3.new(0,-5,0))
  61. game.ReplicatedStorage.madeit:FireAllClients(hit.Parent.Name)
  62. end)
  63. end
  64.  
  65. function handleEvent(player, functionName, args)
  66. if serverFunctions[functionName] then
  67. serverFunctions[functionName](player, args)
  68. end
  69. end
  70.  
  71. remoteEvent.OnServerEvent:connect(handleEvent)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement