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

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

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)

3 comments

0

Format your script by highlighting your script and indenting it.

0

player.leaderstats.Strength.Value------

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

1 answer

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

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