Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script isn't working?

Asked by
rootx 15
10 years ago

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)
0
What keys are you wanting to respond to? AxeOfMen 434 — 10y
0
Also, please describe what you expect to happen and what is actually happening. This will help others help you. AxeOfMen 434 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

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
0
Btw this was done on iPad sorry for simple mistakes DragonSkyye 517 — 10y
Ad

Answer this question