Advertisement
DrawingJhon

Fort Martin (Instant Reset)

Oct 22nd, 2022
812
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | None | 0 0
  1. local remote
  2. for i, v in pairs(game.ReplicatedStorage:GetDescendants()) do
  3.     if v:IsA("RemoteFunction") and v.Name:lower():match("respawn") then
  4.         remote = v
  5.     end
  6. end
  7.  
  8. if _G.ResetChar then
  9.     _G.ResetChar()
  10. end
  11.  
  12. local lastCF
  13. local function charAdded(char)
  14.     local human = char:WaitForChild("Humanoid")
  15.     local root = char:WaitForChild("HumanoidRootPart")
  16.    
  17.     if lastCF then
  18.         spawn(function()
  19.             root.CFrame = lastCF
  20.         end)
  21.     end
  22.    
  23.     human.Died:Connect(function()
  24.         lastCF = root.CFrame * CFrame.new(0, 3, 0)
  25.         task.wait(0.1)
  26.         remote:InvokeServer()
  27.     end)
  28. end
  29.  
  30. local player = game.Players.LocalPlayer
  31. if player.Character then
  32.     charAdded(player.Character)
  33. end
  34.  
  35. local c = player.CharacterAdded:Connect(charAdded)
  36. local run = true
  37.  
  38. _G.ResetChar = function()
  39.     c:Disconnect()
  40.     run = false
  41. end
  42.  
  43. local function getHuman()
  44.     return player.Character and player.Character:FindFirstChildOfClass("Humanoid")
  45. end
  46.  
  47. while run and task.wait(0.1) do
  48.     local human = getHuman()
  49.     if human and human.Health < 0.01 then
  50.         remote:InvokeServer()
  51.     end
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement