Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I make currency transfer to Coins but only half the amount of the currency?

I am currently working on a game, where you have to transfer a currency into Coins. I do not want the exact amount to transfer. I want half of that to transfer. Help! Heres the script it currently just transfers everything:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
    local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        plr.leaderstats.Coins.Value = plr.leaderstats.Coins.Value + plr.leaderstats.Squeaks.Value
        plr.leaderstats.Squeaks.Value = 0
	end
end)

2 comments

0

Well, you would cut the currency in half using amount / 2, and setting the coins value to that.

0

All you have to do is add /2 at the end of line 4 after plr.leaderstats.Squeaks.Value, so it only adds half.

1 answer

✓ Accepted answer

divide by two is the same as "half". just do currency / 2 which makes it half.

This discussion is preserved as it was. New answers, comments, and votes are closed.