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

How do I make a leaderstat multiply a leaderstat?

Asked by 4 years ago

I want the leaderstat Cash to be auto given every 2 minutes. I want 10 Cash to be auto given. But if the player has Multi then the Multi multiplies the Cash given by the amount of the players Multi. Can anyone help me?

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

What I would do is insert a separate value in the player that indicates how much the multiplier is.

game.Players.PlayerAdded:Connect(function(plr)
local multi = Instance.new("IntValue",plr)
multi.Name = "Multiplier"
local leaderstats = Instance.new("Folder",plr)
leaderstats.Name = "leaderstats"
local Cash = Instance.new("IntValue",leaderstats)
Cash.Name = "Cash"
multi.Value = 2 -- lets say the multiplier is * 2
end)

the script above simply inserts the values needed into the player.

--seperate script
game.Players.PlayerAdded:Connect(function(plr)
while true do
plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value + plr.Multiplier.Value * 10 --really just 2*10
wait(120)
end
end)

not checked, please reply if you see any errors. thank you!

0
Thanks for trying but it did not work... @natonator63 User#32519 0 — 4y
0
:/ User#32519 0 — 4y
0
one more thing- they must both be server scripts and in serverscriptservice natonator63 29 — 4y
0
pardon me! i found some errors in the second script and it is now fixed. it should work now. Sorry for the inconvenience natonator63 29 — 4y
View all comments (3 more)
0
I will check tommowrow :) User#32519 0 — 4y
0
Nope, it did not work :/ User#32519 0 — 4y
0
bruh. YOU MAKE TWO SEPERATE SCRIPTS. INSERT THEM IN SERVERSCRIPTSERVICE. AND PUT THESE SCRIPTS IN THERE. natonator63 29 — 4y
Ad

Answer this question