I'm trying to make a time freeze script on roblox. However it doesn't exactly work the way I want it too.
I don't get an error or anything the keys just don't work :/
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local FreezeAll = true -- Freeze all? local admin = "Player1" function anchorPartsSpecific(model) for i, v in pairs(model:GetChildren()) do if v:IsA"Model" and FreezeAll == false and v.Name == "FreezeMe!" then anchorPartsSpecific(v) elseif v:IsA"BasePart" then v.Anchored = true end end end function anchorAll(model) for i, v in pairs(model:GetChildren()) do if v:IsA"Model" and FreezeAll == true then anchorAll(v) elseif v:IsA"BasePart" then v.Anchored = true elseif v.Name == admin then print("player found") end end end function unanchorParts(model) for i, v in pairs(model:GetChildren()) do if v:IsA"Model" then unanchorParts(v) elseif v:IsA"BasePart" then v.Anchored = false end end end Mouse.KeyDown:connect(function(key) if key:byte() == 29 then elseif FreezeAll == true then anchorAll(workspace) elseif FreezeAll == false then anchorPartsSpecific(workspace) elseif key:byte() == 30 then unanchorParts(workspace) end end)
Here is a quick example of how you can do it.
local Parts = {} function Scan(name) for I, v in pairs(name:GetChildren()) do table.insert(Parts, v) If #v:GetChildren() > 0 then Scan(v) end end end Scan(Workspace) for I, v in pairs(Parts) do If v:IsA("Part") then v.Anchored = true end end