Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- repeat wait() until script.Parent.main_script
- local remoteEvent = Instance.new("RemoteEvent", game.Workspace)
- local serverFunctions = {}
- function serverFunctions.spawnCustom(player)
- print(player)
- game.Workspace:WaitForChild(player.Name)
- game.Workspace[player.Name]:WaitForChild("Humanoid")
- local OldCharacter = player.Character
- local OldCharacterLocation = OldCharacter.Torso.Position
- local NewCharacter = game.ServerStorage.NewCharacter:Clone()
- NewCharacter.Name = player.Name
- NewCharacter.Torso.g.t.Text=player.Name
- NewCharacter.Torso.BrickColor = BrickColor.Random()
- NewCharacter.Parent = game.Workspace
- local Humanoid = OldCharacter.Humanoid
- player.Character = NewCharacter
- Humanoid.Parent = NewCharacter
- Humanoid.PlatformStand = true
- OldCharacter:Destroy()
- local SpawnGui = player.PlayerGui:FindFirstChild("SpawnGui")
- if SpawnGui ~= nil then
- SpawnGui:Destroy()
- end
- NewCharacter:MoveTo(workspace.spawnpoint.Position+Vector3.new(0,-5,0))
- for i,v in pairs(workspace.Map.Checkpoints:GetChildren()) do
- v.Touched:Connect(function(h)
- if h.Name == "Head" then
- local calc = v['value'].Value;
- local lastCheckpoint = calc;
- if calc > lastCheckpoint then
- print("new checkpoint reached: "..calc);
- local lastCheckpoint = calc;
- end
- end
- end)
- end
- while 1 do
- for i,v in pairs(workspace.Map.Checkpoints:GetChildren()) do
- local checks = v;
- local dist = (NewCharacter['Torso'].Position - checks.Position).magnitude;
- if dist < 8 then
- local calc = v['value'].Value;
- local lastCheckpoint = calc;
- if calc > lastCheckpoint then
- print("new checkpoint reached: "..calc);
- lastCheckpoint = calc;
- end
- end
- end
- wait();
- end
- workspace.finish.Touched:Connect(function(hit)
- hit.Parent:MoveTo(workspace.spawnpoint.Position+Vector3.new(0,-5,0))
- game.ReplicatedStorage.madeit:FireAllClients(hit.Parent.Name)
- end)
- end
- function handleEvent(player, functionName, args)
- if serverFunctions[functionName] then
- serverFunctions[functionName](player, args)
- end
- end
- remoteEvent.OnServerEvent:connect(handleEvent)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement