Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script isn't working?

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)


2 comments

0

What keys are you wanting to respond to?

0

Also, please describe what you expect to happen and what is actually happening. This will help others help you.

1 answer

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

1 comment

0

Btw this was done on iPad sorry for simple mistakes

This discussion is preserved as it was. New answers, comments, and votes are closed.