Attempt to perform arithmetic (add) on Instance and number

So I was making a game, I found out an error for my game and I got stuck on it. If you can help out, that would be appreciated! I will be hearting every comment in this topic!

Script (Inside a part):

local Players = game:GetService("Players")
local part = script.Parent

local cooldown = false

script.Parent.Touched:connect(function(hit)
	local player = Players:GetPlayerFromCharacter(hit.Parent)
	if cooldown == false then
		if player and player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("MapsCompleted") and player:FindFirstChild("Stats") and player.Stats:FindFirstChild("Maze1Win") then
			if player.Stats.Maze3Win.Value == false then
				hit.Parent:SetPrimaryPartCFrame(CFrame.new(Vector3.new(-121, 3, -619)))
				print("u win lol")
				cooldown = true
				player.leaderstats.MapsCompleted = player.leaderstats.MapsCompleted + 1
				wait(.1)
				player.Stats.Maze3Win.Value = true
				
			elseif player.Stats.Maze3Win.Value == true then
				hit.Parent:SetPrimaryPartCFrame(CFrame.new(Vector3.new(-121, 3, -619)))
				print("u did this again?!!")
			end
		end
	elseif cooldown == true then
		wait(.1)
		cooldown = false
	end
end)

once again, if you can help it would be appreciated!

10 Likes

You forgot to add .Value

player.leaderstats.MapsCompleted.Value += 1

Shorter way of doing it

25 Likes

worked! Sorry if i was careless in a such minor error,but thanks alot! Free heart for you!

10 Likes