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

Why wont this add and and multiply?

Asked by 3 years ago
Edited 3 years ago

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
could you tell us what is happening? that may help us solve your problem raid6n 2196 — 3y

1 answer

Log in to vote
0
Answered by
raid6n 2196 Moderation Voter Community Moderator
3 years ago

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
Ad

Answer this question