hi, im making a script where a number's going down (already done that script) and this script is supposed to check what the number is, and change the parents of some models depending on how big the number is, but it isnt working, can anyone help me?
local RepStorage = game.ReplicatedStorage.BoxTypes local Percent = script.Parent.Percentage while true do if Percent > 90 then script.Parent:FindFirstChild("Danger").Parent = RepStorage script.Parent:FindFirstChild("Open").Parent = RepStorage script.Parent:FindFirstChild("Opening").Parent = RepStorage script.Parent:FindFirstChild("Peeking").Parent = RepStorage RepStorage.Closed.Parent = script.Parent end if Percent < 90 and Percent > 65 then script.Parent:FindFirstChild("Danger").Parent = RepStorage script.Parent:FindFirstChild("Open").Parent = RepStorage script.Parent:FindFirstChild("Opening").Parent = RepStorage script.Parent:FindFirstChild("Closed").Parent = RepStorage RepStorage.Peeking.Parent = script.Parent end if Percent < 65 and Percent > 35 then script.Parent:FindFirstChild("Danger").Parent = RepStorage script.Parent:FindFirstChild("Open").Parent = RepStorage script.Parent:FindFirstChild("Closed").Parent = RepStorage script.Parent:FindFirstChild("Peeking").Parent = RepStorage RepStorage.Opening.Parent = script.Parent end if Percent < 35 and Percent > 10 then script.Parent:FindFirstChild("Danger").Parent = RepStorage script.Parent:FindFirstChild("Opening").Parent = RepStorage script.Parent:FindFirstChild("Closed").Parent = RepStorage script.Parent:FindFirstChild("Peeking").Parent = RepStorage RepStorage.Open.Parent = script.Parent end if Percent <= 10 then script.Parent:FindFirstChild("Open").Parent = RepStorage script.Parent:FindFirstChild("Opening").Parent = RepStorage script.Parent:FindFirstChild("Closed").Parent = RepStorage script.Parent:FindFirstChild("Peeking").Parent = RepStorage RepStorage.Danger.Parent = script.Parent end end
oh yeah blind blind, after you parent something to ReplicatedStorage, it will be in ReplicatedStorage, not in script.Parent, you can, however, put the instances into variables, there they are going to always be accesible no matter where they are:
local RepStorage = game.ReplicatedStorage.BoxTypes local Percent = script.Parent.Percentage local Danger = script.Parent:FindFirstChild("Danger") local Open = script.Parent:FindFirstChild("Open") local Opening = script.Parent:FindFirstChild("Opening") local Peeking = script.Parent:FindFirstChild("Peeking") while true do if Percent.Value > 90 then Danger.Parent = RepStorage Open.Parent = RepStorage Opening.Parent = RepStorage Peeking.Parent = RepStorage Closed.Parent = script.Parent elseif Percent.Value < 90 and Percent.Value > 65 then Danger.Parent = RepStorage Open.Parent = RepStorage Opening.Parent = RepStorage Peeking.Parent = RepStorage Peeking.Parent = script.Parent elseif Percent.Value < 65 and Percent.Value > 35 then Danger.Parent = RepStorage Open.Parent = RepStorage Opening.Parent = RepStorage Peeking.Parent = RepStorage Opening.Parent = script.Parent elseif Percent.Value < 35 and Percent.Value > 10 then Danger.Parent = RepStorage Open.Parent = RepStorage Opening.Parent = RepStorage Peeking.Parent = RepStorage Open.Parent = script.Parent elseif Percent.Value <= 10 then Danger.Parent = RepStorage Open.Parent = RepStorage Opening.Parent = RepStorage Peeking.Parent = RepStorage Danger.Parent = script.Parent end end
ok still hasnt worked but here is the updated script
local RepStorage = game.ReplicatedStorage.BoxTypes local Percent = script.Parent.Percentage while true do if Percent.Value > 90 then script.Parent:FindFirstChild("Danger").Parent = RepStorage script.Parent:FindFirstChild("Open").Parent = RepStorage script.Parent:FindFirstChild("Opening").Parent = RepStorage script.Parent:FindFirstChild("Peeking").Parent = RepStorage RepStorage.Closed.Parent = script.Parent elseif Percent.Value < 90 and Percent.Value > 65 then script.Parent:FindFirstChild("Danger").Parent = RepStorage script.Parent:FindFirstChild("Open").Parent = RepStorage script.Parent:FindFirstChild("Opening").Parent = RepStorage script.Parent:FindFirstChild("Closed").Parent = RepStorage RepStorage.Peeking.Parent = script.Parent elseif Percent.Value < 65 and Percent.Value > 35 then script.Parent:FindFirstChild("Danger").Parent = RepStorage script.Parent:FindFirstChild("Open").Parent = RepStorage script.Parent:FindFirstChild("Closed").Parent = RepStorage script.Parent:FindFirstChild("Peeking").Parent = RepStorage RepStorage.Opening.Parent = script.Parent elseif Percent.Value < 35 and Percent.Value > 10 then script.Parent:FindFirstChild("Danger").Parent = RepStorage script.Parent:FindFirstChild("Opening").Parent = RepStorage script.Parent:FindFirstChild("Closed").Parent = RepStorage script.Parent:FindFirstChild("Peeking").Parent = RepStorage RepStorage.Open.Parent = script.Parent elseif Percent.Value <= 10 then script.Parent:FindFirstChild("Open").Parent = RepStorage script.Parent:FindFirstChild("Opening").Parent = RepStorage script.Parent:FindFirstChild("Closed").Parent = RepStorage script.Parent:FindFirstChild("Peeking").Parent = RepStorage RepStorage.Danger.Parent = script.Parent end end