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

Error - Unable to cast value to object? Tweening descendants transparency.

Asked by 2 years ago
Edited by greatneil80 2 years ago

Ok. So i'm trying to tween a bunch of descendants so that they appear at 6pm, and disappear at 7am. Its giving me an error on the line where I play() the tween, and for the life of me, I don't know why.

Please can you help?

Script is like this. I'm trying really hard to format it properly in this webpage and its not working. I'm sorry the formatting is wrong. Please help me.

local TweenService = game:GetService("TweenService")
local part = script.Parent.nightstuff:GetDescendants()

for _, part in pairs(script.Parent.nightstuff:GetDescendants()) do
    if part:IsA("BasePart") then 

        tweenInfo = TweenInfo.new(
            2, -- Time
            Enum.EasingStyle.Linear, -- EasingStyle
            Enum.EasingDirection.Out, -- EasingDirection
            0, -- RepeatCount (when less than zero the tween will loop indefinitely)
            false, -- Reverses (tween will reverse once reaching it's goal)
            3 -- DelayTime
        )

        TweenService:Create(part,tweenInfo, {Transparency = 1}):play()
    end
end

while wait(4) do
    for _,Player in pairs(game.Players:GetPlayers()) do
        if Player.Character ~= nil then
                if game.Lighting.ClockTime > 18 or game.Lighting.ClockTime < 7 then
                TweenService:Create(part,tweenInfo,{Transparency = 0}):play()
                print "transparency is now 0"
                end

        elseif game.Lighting.ClockTime < 18 and game.Lighting.ClockTime > 7 then
            TweenService:Create(part,tweenInfo,{Transparency = 1}):play()
            print "transparency is now 1"
            end
        end
    end
0
I'll try and post the script again. Tilley_Eyelash 0 — 2y
0
I'll edit it for you greatneil80 2647 — 2y
0
Thank you greatneil80 Tilley_Eyelash 0 — 2y

Answer this question