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

simple script not working ??

Asked by 9 years ago

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

Log in to vote
1
Answered by
Muoshuu 580 Moderation Voter
9 years ago

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
Ad
Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

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

Answer this question