So, I am trying to make a loop that is as fast as it can possibly be on the server. The only thing i know of would be game:GetService'RunService'.Heartbeat, but whenever i teleport a player in that loop, the player is visibly still being pulled down my gravity. What i want is a loop so fast that it makes it seem as if the player is stuck in the air. Why you not just use Anchored, you may ask? I am using the loop for a reason, and that is to prevent exploiters (i wont get into why i am doing this, since that is not my question). Are there any loops faster than Heartbeat (that don't crash the player of course, while 1 do end is not an alternative)?
Any help would be appreciated!
Instead of doing just one of each, why not do both? Anchor the player's HumanoidRootPart and repeatedly set the HumanoidRootPart's position. However, the internet isn't instant and will result in some delay.
-- Server script in ServerScriptService local runService = game:GetService("RunService") local position = CFrame.new() -- 0, 0, 0 local function setPlayersCFrame() local players = game.Players:GetPlayers() for i, plr in ipairs(players) do if plr and plr.Character then local char = plr.Character local humanoidRootPart = char:FindFirstChild("HumanoidRootPart") if humanoidRootPart then humanoidRootPart.Anchored = true humanoidRootPart.CFrame = position end end end end runService.Heartbeat:Connect(setPlayersCFrame)
If that doesn't work, you can always put a local script into the player to loop with less jitter.
-- Local script in player local character = player.Character or player.CharacterAdded:Wait() local position = CFrame.new() local runService = game:GetService("RunService") local function setCharacterCFrame() if character then local humanoidRootPart = character:FindFirstChild("HumanoidRootPart") if humanoidRootPart then humanoidRootPart.Anchored = true humanoidRootPart.CFrame = position end end end runService.RenderStepped:Connect(setCharacterCFrame)
I recommend using the local script for this, as the CFrame is updated every frame.