So I'm making a stat system where certain stuff give you buffs, in this example the player gets a buff to the stat "Speed"
function ChangeStat(char, Stat, amount) game.Workspace.Data[char.Name][Stat].Value = amount + 1 print(workspace.Data[char.Name][Stat].Name.." "..workspace.Data[char.Name][Stat].Value) end ChangeStat(char, "Speed", -.05)
I've confirmed it locates the IntValue correctly, and if I print amount I get the correct output, but when I print the stat's Value after it should've been changed I always recieve whatever it was before, in this case 1 when it should be 0.95.
I could really use some help on this as it really confuses me. Thank you in advance!
You Don't Do
game.Workspace.Data[char.Name][Stat].Value = amount + 1
You do
game.Workspace.Data[char.Name][Stat].Value = game.Workspace.Data[char.Name][Stat].Value + amount
Fixed Script
function ChangeStat(char, Stat, amount) game.Workspace.Data[char.Name][Stat].Value = game.Workspace.Data[char.Name][Stat].Value + amount print(workspace.Data[char.Name][Stat].Name.." "..workspace.Data[char.Name][Stat].Value) end ChangeStat(char, "Speed", -.05)