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

How do you make a bool value go up by 1?

Hello I am making a game that will count how many parts have been generated by instance.new. And I wanted to do it with a bool value.

local part = game.Workspace.Generator
local NumBlocks = game.StarterGui.ScreenGui.NumBlocks
local User = NumBlocks.Parent.User
local Rating = NumBlocks.Parent.Rating
local IntValue = game.ReplicatedStorage.IntValue

while true do
	local LagPart = Instance.new("Part", game.Workspace)
	LagPart.CFrame = LagPart.CFrame * part.CFrame
	LagPart.Transparency = 1
	IntValue.Value = IntValue.Value + 1
	wait(0.1)
	print(IntValue)
end

So basically after one part has been generated it will make the bool value go up by 1. But I get an error saying

ServerScriptService.Generator:11: attempt to perform arithmetic (add) on boolean and number

Please help me fix this. Did I do something wrong?

2 comments

0

lol a bool is true or false

0

change your bool value to a Int value. that should fix the problem

2 answers

Problem:

bool values are true or false

Solution:

local part = game.Workspace.Generator
local NumBlocks = game.StarterGui.ScreenGui.NumBlocks
local User = NumBlocks.Parent.User
local Rating = NumBlocks.Parent.Rating
local intValue = Instance.new("IntValue",game.replicatedStorage)

while true do
    local LagPart = Instance.new("Part", game.Workspace)
    LagPart.CFrame = LagPart.CFrame * part.CFrame
    LagPart.Transparency = 1
    IntValue.Value = IntValue.Value + 1
    wait(0.1)
    print(IntValue)
end

1 comment

0

oh well it still just prints value x a number. Can you do it so that I get a intiger?

local part = game.Workspace.Generator
local NumBlocks = game.StarterGui.ScreenGui.NumBlocks
local User = NumBlocks.Parent.User
local Rating = NumBlocks.Parent.Rating
local IntValue = Instance.new("IntValue",game.Workspace)

while true do
    local LagPart = Instance.new("Part", game.Workspace)
    LagPart.CFrame = LagPart.CFrame * part.CFrame
    LagPart.Transparency = 1
    IntValue.Value = IntValue.Value + 1
    wait(0.1)
    print(IntValue)
end

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