✓ Accepted answer
So at line 8 and 9, you wrote that the variables currency and selling are the VALUES of the intvalues in leaderstats. Then, at line 10, 11 and 12, you wrote the variables, but you added a ".Value" at the end of each variable.
Also, at line 11, you did the selling value x the rebirth value. Altough, if the player has 0 rebirths, it will multiply it by 0 and every number multiplied by 0 equals 0. I see you did Rebirth.value + 1, but the code will run the multiplications and the divisions FIRST, then the additions and substractions.
Also, you are obligated to put this code in a script and not in a localscript cuz localscripts can't detect Touching. However, at line 5, you wrote game.Players.LocalPlayers and game.Players.LocalPlayers can only be runned in a localscript.
What I suggest is to do:
local Part = script.Parent
Part.Touched:Connect(function(HIT)
local H = HIT.Parent:FindFirstChild("Humanoid")
if H then
local player = game.Players:WaitForChild(HIT.Parent.Name)
if player then
local leaderstats = player:WaitForChild("leaderstats")
local currency = leaderstats.Cash
local selling = leaderstats.Ducks
if selling.Value > 0 then
Currency.Value = Currency.Value + Selling.Value * 1 * (leaderstats.Rebirth.Value +1)
end
end
end
end)
So I've changed the variables currency and selling and I added brackets to the Rebirth's Value so it will add 1 to it before multiplicating with the player's Ducks's Value.
Also, I've changed the variable player because it could not work in a script. I got the name of the parent of HIT, so the player's character's name, then I got it in the game.Players, because the player's character's name is the same as the player's name in game.Players.
I really hope this helped!
4 comments
Use a code block and explain what the script is suppose to do or we can't help.
ok
help
I helped