Advertisement
Guest User

Scripting Help

a guest
Apr 24th, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1.  
  2. local fakeChar = game.ServerStorage.CustomCharacter -- The character to load
  3. local respawnTime = 2.5 -- How many seconds the player remains dead before they respawn
  4.  
  5. game.Players.CharacterAutoLoads = false -- Disable default character loading
  6.  
  7. function playerAdded(player)
  8.     if player.Character and player.Character.Parent then -- Destroy an already-existing character
  9.         player.Character:Destroy()
  10.     end
  11.  
  12.     while player.Parent do -- Repeat until they leave the game
  13.         loadChar(player) -- Method waits until they die
  14.         game.StarterPack.Claw.Enabled = true
  15.         wait(respawnTime)
  16.     end
  17. end
  18.  
  19. function loadChar(player)
  20.     local char = fakeChar:clone()
  21.     char.Name = player.Name
  22.     char.Humanoid.WalkSpeed = 12
  23.     local humanoid
  24.     for i, child in pairs(char:GetChildren()) do -- Find the humanoid
  25.         if child.ClassName == "Humanoid" then
  26.             humanoid = child
  27.             break
  28.         end
  29.     end
  30.  
  31.     if not humanoid then -- If no humanoid was found, make one
  32.         humanoid = Instance.new("Humanoid", char)
  33.     end
  34.  
  35.     player.Character = char
  36.     char.Parent = game.Workspace
  37.     humanoid.Died:wait() -- Wait until they die
  38. end
  39.  
  40. game.Players.PlayerAdded:connect(playerAdded)
  41.  
  42. for i, player in pairs(game.Players:GetPlayers()) do -- Play Solo support
  43.     if player.Character then
  44.         player.Character:Destroy()
  45.     end
  46.  
  47.     playerAdded(player)
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement