local OwnerName = script.Parent.Parent.Parent.Owner local MoneyStorage = game:GetService('ServerStorage').MoneyStorage local Money = MoneyStorage:FindFirstChild(OwnerName) local Injuries = script.Parent.Parent.Parent.Injuries local InjuryRate = script.Parent.InjuryRate local MoneyLostOnLawsuit = script.Parent.MoneyLostOnLawsuit function Lawsuit() if script.Parent.MachineOn.Value == true then MoneyLostOnLawsuit.Value = Money.Value - (Money.Value * ((Injuries.Value * InjuryRate.Value)/1000)) Money.Value = Money.Value - MoneyLostOnLawsuit.Value print ("Money lost in lawsuit: " .. MoneyLostOnLawsuit.Value) OwnerName.Value.PlayerGui.LawsuitPopup.TextButton.Visible = true OwnerName.Value.PlayerGui.LawsuitPopup.TextButton.Text = ("You have recently been sued due to injuries caused by your medication! Money Lost: " .. MoneyLostOnLawsuit.Value .." Prevent this by researching methods of protection!") wait (0.1) else print ("Machine is off, lawsuit will not occur!") wait (0.1) end end wait (10) Lawsuit()
When this script runs I get an Index Upvalue 'Money' ( a nil value) error on the line "MoneyLostOnLawsuit.Value = Money.Value-(Money.Value * ((Injuries.Value * InjuryRate.Value)/1000))
Is this happening because I reference Money.Value twice?
I dont really see how this isn't working and if somebody could give some insight that would be great.
Thank you!
Most likely it is because of lines 1-3. Change it to this:
local OwnerName=script.Parent.Parent.Parent.Owner local MoneyStorage=game.ServerStorage:WaitForChild("MoneyStorage") local Money=MoneyStorage:WaitForChild(OwnerName.Value)
Hope this helped!