Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

simple script not working ??

cant figure out what the problem is @.@""

set = script.Parent.Settings
money = set.Money.Value --0
rate = set.Rate.Value   --1
Time = set.Time.Value   --1
while true do
	wait (Time)
	money = money + rate
end

2 answers

When setting a variable, you are setting it to the exact thing you point to, meaning 'Money.Value' would set the variable 'money' to the value of 'Money'. Changing this variable will not change the value of 'Money', only the variable 'money'

Use this code:

local Set=script.Parent.Settings
local Money=Set.Money
local Rate=Set.Rate.Value
local Time=Set.Time.Value
while true do
	wait(Time)
	Money.Value=Money.Value+Rate
end

I don't see anything wrong with your script, but you could consider defining the variables inside the loop. This way, if you were to update any of the settings, it would correspond with those updates.

local set = script.Parent.Settings

while true do
	local money = set.Money.Value
	local rate = set.Rate.Value
	local Time = set.Time.Value
	money = money + rate
	wait (Time)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.