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

Why wont this add and and multiply?

I am trying to multiply a value with a value but it wont work. On line 10 is where the values are being added and multiplied

local shopkeeper = game.Workspace:FindFirstChild("Sell your ore here!")
local guiNoticeEvent = game.ReplicatedStorage:WaitForChild("GUINoticeEvent")
RepStor = game:GetService("ReplicatedStorage")
function onTouch(hit)
	local humanoid = hit.Parent:FindFirstChild("Humanoid")
	if (humanoid and humanoid ~= shopkeeper) then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if (player.InventoryValue.Value > 0) then
			local savedValue = RepStor[player.Pickaxe.Value].multiplier.Value * player.RebirthMultipler.Value * player.InventoryValue.Value
			player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + player.InventoryValue.Value * RepStor[player.Pickaxe.Value].multiplier.Value * player.RebirthMultipler.Value 
			player.InventoryValue.Value = 0
			player.InventoryCount.Value = 0
			guiNoticeEvent:FireClient(player, 0, savedValue)
		end
	end
end
script.Parent.Touched:Connect(onTouch)

where coins are generated

local guiNoticeEvent = game.ReplicatedStorage:WaitForChild("GUINoticeEvent")
function guiNotice(opcode, argl)
	if (opcode == 0) then
		local player = game.Players.LocalPlayer
		local playerGui = player:WaitForChild("PlayerGui")
		local text = Instance.new("TextLabel")
		text.Parent = playerGui.MainGui
		text.Name = "CoinsLabel"
		text.Font = Enum.Font.Highway
		text.Size = UDim2.new(0, 200, 0, 50)
		text.AnchorPoint = Vector2.new(0.5, 0.5)
		text.Position = UDim2.new(0.5, 0, 1, -90)
		text.TextSize = 40
		text.TextColor3 = Color3.fromRGB(255, 255, 0)
		text.Text = "+" .. argl .. " Coins"
		text.TextStrokeTransparency = 0
		text.BorderColor3 = Color3.fromRGB(27, 42, 53)
		text.BorderSizePixel = 1
		text.BackgroundTransparency = 1
		text.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
		text:TweenPosition(UDim2.new(0.5, 0, 1, -90), "In", "Back", 1, false, nil)
		wait(4)
		text:TweenPosition(UDim2.new(0.5, 0, 1, 50), "Out", "Back", 1, false, nil)
		wait(1)
		text:Destroy()
	elseif (opcode == 1) then
		local player = game.Players.LocalPlayer
		local playerGui = player:WaitForChild("PlayerGui")
		local text = Instance.new("TextLabel")
		text.Parent = playerGui.MainGui
		text.Name = "AlertLabel"
		text.Font = Enum.Font.Highway
		text.Size = UDim2.new(0, 200, 0, 50)
		text.AnchorPoint = Vector2.new(0.5, 0.5)
		text.Position = UDim2.new(0.5, 0, 1, -90)
		text.TextSize = 40
		text.TextColor3 = Color3.fromRGB(255, 0, 0)
		text.Text = "Backpack is full"
		text.TextStrokeTransparency = 0
		text.BorderColor3 = Color3.fromRGB(27, 42, 53)
		text.BorderSizePixel = 1
		text.BackgroundTransparency = 1
		text.TextStrokeColor3 = Color3.fromRGB(0, 0, 0)
		text:TweenPosition(UDim2.new(0.5, 0, 1, -90), "In", "Back", 1, false, nil)
		wait(4)
		text:TweenPosition(UDim2.new(0.5, 0, 1, 50), "Out", "Back", 1, false, nil)
		wait(1)
		text:Destroy()
	end
end
guiNoticeEvent.OnClientEvent:Connect(guiNotice)

1 comment

1

could you tell us what is happening? that may help us solve your problem

1 answer

✓ Accepted answer

We resolved many things in the chat, but he forgot to multiply the saved value.

Edited line 8:

local savedValue = RepStor[player.Pickaxe.Value].multiplier.Value * player.InventoryValue.Value

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