#EternityNum

20 messages · Page 1 of 1 (latest)

shell mist
#

Hi, i have a bug in a script that when eternitynum convert the value to 1000 to 1k after its stop to work because of an error :
ServerScriptService.ClickEvent:34: attempt to perform arithmetic (add) on string and number - Serveur - ClickEvent:34

script :

local event = game.ReplicatedStorage.Remotes.RemoteEvent
local petModule = require(game.ServerScriptService.PetMod)
local en = require(game.ServerScriptService.EternityNum)


local trainclick = {
    ["train1"] = 1,
    ["train2"] = 1,
    ["train3"] = 1,
    ["train4"] = 1,
    ["train5"] = 1,
    ["train6"] = 1,
    ["train7"] = 1,
    ["train8"] = 1
}

local animPlaying = {}


event.OnServerEvent:Connect(function(player, arg, amount)
    if arg == "Click" and not animPlaying[player] then
        local leaveButton = player.PlayerGui.Menu.Leave
        
        local muscleValue = player.leaderstats.Muscle.Value

        leaveButton.MouseButton1Click:Connect(function()
        end)

        local petboost = petModule.PetBoost(player)

        local trainType = player:GetAttribute("Enable")
        if trainclick[trainType] then
            
            muscleValue += trainclick[trainType] * petboost
            player.leaderstats.Muscle.Value = en.short(muscleValue)

        end


        local animationSpeed = 0.5 + (math.min(muscleValue ^ 0.25 / 20, 13))
        animationSpeed = math.min(animationSpeed, 14)

        animPlaying[player] = true

        for i, v in pairs(player.Character.Humanoid:GetPlayingAnimationTracks()) do
            v:Stop()
        end

        task.wait(0.001)
        if player:GetAttribute("Enable") ~= "" then
            local animationid = "rbxassetid://121846064478166"
            local anim = Instance.new("Animation")
            anim.AnimationId = animationid
            local humanoid = player.Character:WaitForChild("Humanoid")
            local animationTrack = humanoid:LoadAnimation(anim)

            animationTrack:Play()
            animationTrack:AdjustSpeed(animationSpeed)

            animationTrack.Stopped:Connect(function()
                local reverseAnim = Instance.new("Animation")
                reverseAnim.AnimationId = "rbxassetid://113153233667550"
                local reverseTrack = humanoid:LoadAnimation(reverseAnim)
                reverseTrack:Play()

                reverseTrack:AdjustSpeed(animationSpeed)

                reverseTrack.Stopped:Connect(function()
                    animPlaying[player] = false

                    local animationid = "rbxassetid://86869288899495"
                    local anim = Instance.new("Animation") 
                    anim.AnimationId = animationid
                    local humanoid = player.Character:WaitForChild("Humanoid")
                    local animationTrack = humanoid:LoadAnimation(anim)
                    animationTrack:Play()
                end)
            end)    
        end
    end
end)
line 32 to 37 :
        if trainclick[trainType] then
            
            muscleValue += trainclick[trainType] * petboost
            player.leaderstats.Muscle.Value = en.short(muscleValue)

        end

(line 34 is muscleValue += trainclick[trainType] * petboost)

pallid dust
#

eternitynum doesnt have metamethods to do += or *, you should use the in made functions from eternity num

pallid dust
#

it is documented on the own module of eternitynum

shell mist
# pallid dust it is documented on the own module of eternitynum

ok but i maid this :

local increment = en.mul(trainclick[trainType], petboost)
muscleValue = en.add(muscleValue, increment.Exp)
player.leaderstats.Muscle.Value = en.short(muscleValue)

and i have this error :
ServerScriptService.EternityNum:245: invalid argument #1 to 'sign' (number expected, got nil) - Serveur - EternityNum:245
idk why

pallid dust
#

well, expects number and u sent nil

#

muscleValue = en.add(muscleValue, increment.Exp)
ig is this idk the exact line

shell mist
#

its line 35

pallid dust
#

which is it

#

there's 3 lines there

shell mist
#

muscleValue = en.add(muscleValue, increment.Exp)

pallid dust
#

muscleValue is nil

shell mist
#

i don't send but there is :
local muscleValue = player.leaderstats.Muscle.Value

#

in game

pallid dust
#

to the functions of eternitynum you should pass a eternity num converted

shell mist
#

local muscleValue = en.fromString(muscleValue)
and same error

plucky hillBOT
#

studio** You are now Level 4! **studio

shell mist
#

i try with fromnumber and convert

pallid dust
#

i mean js read the documentation and how it works

shell mist
#

ok...