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

roblox multiply the coins?

I doing a game with my friend and i'm doing a shop with items and pets that gives coins but i will do a item that gives you x2 coins and i don't know how to do it (working with leaderstats)

script from the item:

local Tool = script.Parent local hold = false local deb = false local player = Tool.Parent:IsA("Model") and game.Players:GetPlayerFromCharacter(Tool.Parent) or Tool.Parent.Parent local char = player.Character function Press() if player and player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Coins") and player:FindFirstChild("CoinBoost") then local stats = player:WaitForChild("leaderstats") local cash = stats:WaitForChild("Coins") --// Example: "Points","Cash" your currency name Here change for your leaderstats! local boost = player:WaitForChild("CoinBoost") --// this is pet boost local pgui = player:WaitForChild("PlayerGui") local gui = pgui:WaitForChild("ToolPopUp") cash.Value = cash.Value + 1 + boost.Value --"1 Coin + the Value boost :)" gui:WaitForChild("Load"):TweenSize(UDim2.new(0.241, 0,0.1, 0), "Out" , "Linear", 0.5,false,function() --// 0.3 is time for animation! gui:WaitForChild("Load").Size = UDim2.new(0.008, 0,0.1, 0) end) end end game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) if player:WaitForChild("PlayerGui"):FindFirstChild("ToolPopUp") then player["PlayerGui"].ToolPopUp:Destroy() hold = false end end) end) script.Parent.Equipped:Connect(function() local char = script.Parent.Parent local plr = game.Players:GetPlayerFromCharacter(char) local gui = script:FindFirstChild("ToolPopUp") if gui then if not plr:WaitForChild("PlayerGui"):FindFirstChild("ToolPopUp") then gui:Clone().Parent = plr:WaitForChild("PlayerGui") end end end) script.Parent.Unequipped:Connect(function() hold = false local plr = script.Parent.Parent.Parent if plr:WaitForChild("PlayerGui"):FindFirstChild("ToolPopUp") then plr:WaitForChild("PlayerGui"):FindFirstChild("ToolPopUp"):Destroy() end end) script.Parent.Deactivated:Connect(function() hold = false end) script.Parent.Activated:Connect(function() if deb == false and hold == false then local character = Tool.Parent; local humanoid = character.Humanoid if humanoid == nil then return end hold = true repeat wait() if deb == false then deb = true Press() wait(0.5) deb = false end until hold == false end end)

4 comments

0

We need to see the coin giver code to solve this.... Also what variable the item changes

0

cash.Value = cash.Value + 1 + boost.Value

0

cash.Value + 1 is for the tool and + boost.Value for the pets i need to x2 that

0

I suggest posting a more constructive question. For the logic on how to double coins, just set the coins to the value of the coins currently multiplied by 2.

1 answer

Just like that

local Increment = Instance.new("NumberValue",script.Parent)
Increment.Name = "IncrementValue"
Increment.Value = 1 --Change the instance NumberValue to 2 from the item script

cash.value = cash.Value + Increment.Value --Increment line

1 comment

0

i think with the script that i have it's not working

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