IM ABOUT TO CRASH OUT. HELP.
HOW DO YOU FIX THIS?? I HAVE BEEN TRYING FOR 2 HOURS. I'm trying to make it so that when you load in your movement is set to 0 and you become invisible. Here's the code:
local function freezePlayer(character)
local humanoid = character:WaitForChild("Humanoid", 5)
local rootPart = character:WaitForChild("HumanoidRootPart", 5)
if not humanoid then
warn("Humanoid not found for character: " .. character.Name)
return
end
if not rootPart then
warn("HumanoidRootPart not found for character: " .. character.Name)
return
end
for _, part in pairs(character:GetDescendants()) do
if part:IsA("BasePart") then
part.Transparency = 1
part.CanCollide = false
end
end
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
humanoid.PlatformStand = true
rootPart.Anchored = true
print("Character frozen and made invisible:", character.Name)
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
freezePlayer(character)
end)
if player.Character then
freezePlayer(player.Character)
end
end)