while true do
local price = game.Players.LocalPlayer.CPS.Value * 100
script.Parent.Text = game.Players.LocalPlayer.CPS.Value…" Cash Per Seccond (“…price”)"
wait(0.1)
end
this is my code and i dont know what i did wrong plz help me.
while true do
local price = game.Players.LocalPlayer.CPS.Value * 100
script.Parent.Text = game.Players.LocalPlayer.CPS.Value…" Cash Per Seccond (“…price”)"
wait(0.1)
end
this is my code and i dont know what i did wrong plz help me.
Note that function calls are valid without parentheses if a single table/string literal argument is passed. Lua thinks you are trying to call price
; a number value.
Here is your revised script using better practices.
local client = game:GetService("Players").LocalPlayer
local cps = client.CPS
local price = cps.Value*100
cps.Changed:Connect(function(new_cps)
script.Parent.Text = string.format("%d Cash Per Second (%d)", new_cps, price)
end)
string.format
in this case would plug in the numbers where the "%d"
format specifiers are. And this code only executes when the CPS value changes because that is when this code should be executing. Not arbitrarily every 1/10th of a second.