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

Unable to cast value to Object?

Asked by 9 years ago

I made an Income script, but I'm getting this error : "Unable to cast value to Object". Here's the entire script for you to see

Income = script.Parent.Configuration.Income
CashAmount = Income.Cash.Amount
ResearchAmount = Income.Research.Amount

Time = Income.Time

Owner = Income.Parent.Tycoon.Owner
wait()
local Player = game.Players:GetPlayerFromCharacter(Owner.Value)
local Stats = Player:FindFirstChild("Stats")
Cash = Stats:FindFirstChild("Cash")
Research = Stats:FindFirstChild("Research")

while wait(Time.Value) do
    Cash.Value = Cash.Value + CashAmount.Value
    Research.Value = Research.Value + ResearchAmount.Value
end

My hierarchy of my game is like this :

Workspace - Space Agency (M) -- Income (S) -- Configuration (C) --- Income (OV) ---- Cash (OV) ----- Amount (IV) ---- Research (OV) ----- Amount (IV) ---- Time (IV)

Where : (M) Model ; (S) Script ; (C) Configuration ; (OV) ObjectValue ; (IV) IntValue

Thanks!

0
What line is giving you that error? adark 5487 — 9y

Answer this question