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

Trying to add a number to an int value can't figure it out please help?

Asked by 3 years ago
Edited by Ziffixture 3 years ago

Please encode Lua code in the Lua block code tag (look for the Lua icon in the editor).

My bug says   ServerScriptService.Remotes:10: attempt to perform arithmetic (add) on Instance and number  -  Server  -  Remotes:10

And here is my code Stats: The problem is in remotes line 10

player.leaderstats.Strength.Value = player.leaderstats.Strength + 15 * player.leaderstats.Rebirths.Value + 1

local ServerStorage = game:GetService("ServerStorage")
game.Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player
    local strength = Instance.new("NumberValue")
    strength.Name = "Strength"
    strength.Parent = leaderstats
    local rebirths = Instance.new("IntValue")
    rebirths.Name = "Rebirths"
    rebirths.Parent = leaderstats

    local dataFolder = Instance.new("Folder")
        dataFolder.Name = player.Name
        dataFolder.Parent = ServerStorage.remoteData

        local debounce = Instance.new("BoolValue")
        debounce.Name = "Debounce"
        debounce.Parent = dataFolder
    print("Stats work")
end)
Remotes:
local replicatedStorage = game:GetService("ReplicatedStorage")
local remoteData = game:GetService("ServerStorage"):WaitForChild("remoteData")
local cooldown = 1
replicatedStorage.Remotes.Lift.OnServerEvent:Connect(function(player)
    if not remoteData:FindFirstChild(player.Name)then return "NoFolder" end
    local Debounce = remoteData[player.Name].Debounce
    if not Debounce.Value then
        Debounce.Value = true
        print("got past")
        player.leaderstats.Strength.Value = player.leaderstats.Strength + 15 * player.leaderstats.Rebirths.Value + 1
        wait(cooldown)
        Debounce.Value = false  
        print("I did it!")
    end
end)
0
Format your script by highlighting your script and indenting it. LeedleLeeRocket 1257 — 3y
0
player.leaderstats.Strength.Value------ Ziffixture 6913 — 3y
0
player.leaderstats.Strength.Value = player.leaderstats.Strength + 15 * player.leaderstats.Rebirths.Value + 1 - in this line, there is a missing data. to the "player.leaderstats.Strength" add to the end a .Value BlackFateX 19 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

I found the problem, it needs to be player.leaderstats.Strength.Value = player.leaderstats.Strength.Value + 15 * player.leaderstats.Rebirths.Value + 1

Ad

Answer this question