Advertisement
XxMirayxX21

gainownership

Apr 20th, 2021
1,266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.40 KB | None | 0 0
  1. -- H3x0Rs Ownership Script v2.1.1
  2. local PlayerInstance;
  3. local sethiddenprop = (sethiddenproperty or set_hidden_property or sethiddenprop or set_hidden_prop)
  4. local setsimulationrad = setsimulationradius or set_simulation_radius or function(Radius) sethiddenprop(PlayerInstance, "SimulationRadius", Radius) end
  5. if not getgenv or not sethiddenprop or not setsimulationrad then return false end -- Not supported
  6. if NETWORKOWNER then NETWORKOWNER:Disconnect() NETWORKPLAYERCHECK:Disconnect() NETWORKPLAYERCHECK2:Disconnect() end
  7. getgenv().NETWORK_RADIUS = NETWORK_RADIUS or math.huge
  8.  
  9. if not isfile("network-ownership.log") then
  10.     writefile("network-ownership.log", "Script executed on game "..game.PlaceId.."!\n")
  11. else
  12.     appendfile("network-ownership.log", "Script executed on game "..game.PlaceId.."!\n")
  13. end
  14.  
  15. if not game:IsLoaded() then
  16.     appendfile("network-ownership.log", "Waiting for game to load...\n")
  17.     game.Loaded:Wait() -- Wait for game
  18. end
  19.  
  20. -- Grab services
  21. local RunService = game:GetService("RunService")
  22. local Players = game:GetService("Players")
  23. PlayerInstance = Players.LocalPlayer
  24.  
  25. -- Optimize
  26. local PlayerList = {}
  27. for _, Plr in pairs(Players:GetPlayers()) do
  28.     if Plr ~= PlayerInstance then
  29.         PlayerList[Plr] = true
  30.     end
  31. end
  32.  
  33. getgenv().NETWORKPLAYERCHECK = Players.PlayerAdded:Connect(function(Plr)
  34.     PlayerList[Plr] = true
  35. end)
  36.  
  37. getgenv().NETWORKPLAYERCHECK2 = Players.PlayerRemoving:Connect(function(Plr)
  38.     local Success, Err = pcall(function() PlayerList[Plr] = nil end)
  39.     if not Success then
  40.         appendfile("network-ownership.log", "Error while de-registering player that left: "..tostring(Err).."\n")
  41.     end
  42. end)
  43.  
  44. -- Configure network services
  45. settings().Physics.AllowSleep = false -- Keep the current physics system from sleeping. (Non-moving parts lose ownership.)
  46. settings().Physics.PhysicsEnvironmentalThrottle = Enum.EnviromentalPhysicsThrottle.Disabled -- Keep the physics from throttling.
  47.  
  48. -- Start network runtime
  49. getgenv().NETWORKOWNER = RunService.Stepped:Connect(function()
  50.     -- Revoke ownership from others
  51.     for Plr, _ in pairs(PlayerList) do
  52.         sethiddenprop(Plr, "MaximumSimulationRadius", 0.01)
  53.         sethiddenprop(Plr, "SimulationRadius", 0.01)
  54.     end
  55.  
  56.     -- Claim ownership for me
  57.     sethiddenprop(PlayerInstance, "MaximumSimulationRadius", NETWORK_RADIUS)
  58.     setsimulationrad(NETWORK_RADIUS)
  59. end)
  60.  
  61. return true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement