o1-mini-2024-09-12· OpenAI
WildChat-4.8M (AI2)
code with no commentaryx a lua scrit for my roblox game fixing any object whenplaying…
- User
code with no commentaryx a lua scrit for my roblox game fixing any object whenplaying falling or player falling fix completly add all checks needed short variable coding use techniques and coding style what pro developers use
- Assistant
local Players = game:GetService("Players") local RunService = game:GetService("RunService") local Threshold = 50 local CorrectionHeight = 50 local function fixCharacter(char) local hrp = char:FindFirstChild("HumanoidRootPart") local humanoid = char:FindFirstChildOfClass("Humanoid") if hrp and humanoid then if hrp.Position.Y < -Threshold then hrp.CFrame = CFrame.new(0, CorrectionHeight, 0) humanoid:TakeDamage(humanoid.Health) elseif humanoid:GetState() == Enum.HumanoidStateType.Freefall then humanoid.PlatformStand = true wait(0.5) humanoid.PlatformStand = false end end end local function fixObject(obj) if obj:IsA("BasePart") then if obj.Position.Y < -Threshold then obj.Position = Vector3.new(0, CorrectionHeight, 0) obj.Velocity = Vector3.new(0,0,0) obj.RotVelocity = Vector3.new(0,0,0) end end end RunService.Heartbeat:Connect(function() for _, player in ipairs(Players:GetPlayers()) do if player.Character then fixCharacter(player.Character) end end for _, obj in ipairs(workspace:GetDescendants()) do fixObject(obj) end end)