Hi, I’m trying to make a textLabel show the product of a multiplication problem. This is my first time trying it so I’m not sure if I’m even supposed to do it like this.
local upgrades = game.Players.LocalPlayer:WaitForChild("UpgradesIntValue", 1) -- UpgradesIntValue is an IntValue under StarterPlayer and it's value is set to 1
local increase = 1.5
while true do
script.Parent.Text = upgrades*increase
end
----THIS SCRIPT IS UNDER THE TEXT LABEL
15:47:29.368 - Players.Play_MazeOfHeck.PlayerGui.ScreenGui2.Upgrade.Cost.Cost:5: attempt to perform arithmetic (mul) on nil and number
If Instance::WaitForChild can’t find UpgradesIntValue within 1 second then it’s going to return nil. Consider waiting until it’s found. I am not sure if you knew what the second argument was for.
Also you need to multiply the Value not the instance itself
local upgrades = game:GetService("Players").LocalPlayer:WaitForChild("UpgradesIntValue")
local increase = 1.5
upgrades.Changed:Connect(function(new)
script.Parent.Text = new*increase
end)
With your script, studio would hang since there is no yielding in your infinite loop. I used the Changed event instead since it ONLY fires on the Value property changing.