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

Disappearing Plates script keeps breaking, help?

Asked by 8 years ago

In my minigames, everything goes well... the choosing random minigame, the teleporting, but when a few plates disappear, this comes out in the output:

06:33:40.238 - Transparency is not a valid member of Model 06:33:40.238 - Script 'Workspace.DisappearingPlates.removePlates', Line 25 - local disappearingPlates 06:33:40.239 - Script 'Workspace.DisappearingPlates.removePlates', Line 33 06:33:40.239 - Stack End


-- The function while wait(1) do local function disappearingPlates() local plates = script.Parent:GetChildren() local ranNum1 = plates[math.random(1, #plates)] -- problem :( local ranNum2 = plates[math.random(1, #plates)] --while ranNum1 == ranNum2 do --wait() --ranNum2 = plates[math.random(1, #plates)] --end for i = 0, 1, 0.05 do wait() ranNum1.Transparency = i ranNum2.Transparency = i end ranNum1:Destroy() ranNum2:Destroy() end disappearingPlates() -- problem :( end -- end of script :D
0
So please, if you could help out that would be great :) Alucifer 45 — 8y
0
You are indexing the children of a model which contains (probably) Parts, your Script that you wrote up there and, based on error, 1 or more models. You should create a separate model to store only the Parts and index that. LetThereBeCode 360 — 8y
0
Could you show us a picture of the explorer with all folds opened involving the plates. General_Scripter 425 — 8y

1 answer

Log in to vote
2
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
8 years ago

Your Problem

Your problem is that either ranNum1 or ranNum2 is returning a model. And since you index the Transparency property on line 19 and 20 then it is going to error if either variable is a model due to the fact the models don't have the Transparency property - hence your error Transparency is not a valid member of Model.




Code

--[[You should really consider putting your function on the outside of the while loop, otherwise you're re-defining the function every time the loop iterates.]]

function disappearingPlates()
    local children,plates = script.Parent:GetChildren(),{}
    --Create a table filled only with parts.
    for _,v in next,children do
        if v:IsA("BasePart") then
            table.insert(plates,v)
        end
    end
    --Select randomely from created table
    local ranNum1 = plates[math.random(1, #plates)]
    local ranNum2 = plates[math.random(1, #plates)]
    --Change ranNum2's value as long as it is equal to ranNum1
    while ranNum1 == ranNum2 and wait() do
        ranNum2 = plates[math.random(1, #plates)]
    end
    for i = 0, 1, 0.05 do
        wait()
        ranNum1.Transparency = i
        ranNum2.Transparency = i
    end
    ranNum1:Destroy()
    ranNum2:Destroy()
end

while wait(1) do
    disappearingPlates()
end
0
Thanks man, that really helped! Alucifer 45 — 8y
0
Anytime :) Goulstem 8144 — 8y
Ad

Answer this question