Unable to cast value to Object

  1. What do you want to achieve?
    Using TweenService to move the BillboardGui with the TextLabel as smooth as possible.

  2. What is the issue?
    I get an error at the line with the TweenService:Create() calls.

local Billboard = Instance.new("BillboardGui")
Debris:AddItem(Billboard, 1);
Billboard.Adornee = Character["Head"];
Billboard.Size = UDim2.new(0, 200, 0, 30)
Billboard.Parent = Character;
Billboard.AlwaysOnTop = true;
local TextLabel = Instance.new("TextLabel")
TextLabel.Size = UDim2.new(1, 0, 1, 0)
TextLabel.BackgroundTransparency = 1;
TextLabel.Font = Enum.Font.SourceSansLight;
TextLabel.TextColor3 = Color3.new(0, 1, 0)
TextLabel.TextScaled = true;
TextLabel.Text = "Hierophant Green!";
TextLabel.Parent = Billboard;
local Offset = math.random(-2, 2)
TweenService:Create(Billboard, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {StudsOffset = Vector3.new(Offset, 1, 0)}):Play();
TweenService:Create(TextLabel, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Rotation = (22.5 * Offset);TextTransparency=1}):Play();


  1. What solutions have you tried so far?
    I’ve tried debugging but I couldn’t seem to find out what my problem was. I’ve looking around the forum for answers but everything else seems to be different. If someone has a solution, it would be appreciated. I would also like to note that every other TweenService:Create():Play() calls with parts and SpecialMeshes work. But, working with BillboardGui seems to not function.
1 Like

StudsOffset is a property of BillBoardGuis, but you’ve input your TextLabel object as the object to tween on both lines, I assume you meant to put Billboard on the first :Create() line.

Oh, sorry I put Billboard in the original script, I just miswrote. Fixed that, but I still get the error.

The Billboard may be getting destroyed too quickly as you’ve added it to Debis. You should perhaps destroy it when the tween has completed.

It didn’t seem to work. I moved the Debris:AddItem() line in front of the Tween and gave it more time in the Debris:AddItem() call to complete, but it didn’t seem to work. I would like to say, though, it does appear the way it should, but it doesn’t move nor fade. It just disappears when Debris takes it away.

As you can see, the text appears but doesn’t fade nor does it move at all. Then, I get the same error.
(Ignore that it’s a warning, it’s for debugging purposes.)

Try using the .Completed event of a tween and then add the billboard to debris. Utilising basic knowledge when it comes to events, you can either wait for the tween to complete by doing tween.Completed:Wait() or you could connect a function to it like so tween.Completed:Connect(function() etc.

I doubt that it’ll work because removing Debris:AddItem() didn’t work.

I tried using command bar when testing in Studio, then it functioned as intended. But, this doesn’t explain why it doesn’t work when I try with the actual script.