Script not printing

I am making a game with a sword, and I want it to print something while a boolValue is true, but it is not printing

local char = script.Parent.Parent.Parent
while script.Parent.Blocking == true do
	wait(.1)
	print("Blocking")
end

Blocking is a BoolValue
This is running inside of a regular script inside of a tool

script.parent will reference the tool, not the character. the char value wont even get the character if i understand correctly

It prints the character perfectly fine when outside of the loop

1 Like

is the blocking boolvalue inside the tool or the character?

here where you say

while script.Parent.Blocking == true do
while script.Parent.Blocking.Value == true do

If you dont put .Value after “Blocking” it wont work

3 Likes

ive made that mistake more times than you can imagine

2 Likes

me too, and more times then i would like to admit :joy:

3 Likes

Currently you are checking if the object “Blocking” is true. You need to put .Value to get the value of that bool (As in script.Parent.Blocking.Value). Which will be either true or false since it’s a bool. This applies to ALL values (Bool, Int, String, etc.)

while script.Parent.Blocking.Value == true do
	wait(.1)
	print("Blocking")
end

Still won’t work

while script.Parent.Blocking.Value == true do
	wait(.1)
	print("Blocking")
end

Still wont work

The script is inside of the tool

I decided that blocking doesnt really fit the theme of my game, so I decided to entirely remove it, thank you for trying to help

I strongly advise that you try and figure out why your script isn’t working regardless of whether or not you want to have blocking in your game or not. This should be a relatively easy script to make and would provide as a great learning opportunity if there is something about it that you don’t understand. It’s those little problems that you solve over the months/years that make you a great scripter.

Avoid abandoning it until we get to an actual solution, in case others have the same issue!


I suspect that you should be putting it within a value changed event, because I assume that it is not immediately going to be set to true:

local char = script.Parent.Parent.Parent
script.Parent.Blocking.Changed:Connect(function()
	while script.Parent.Blocking == true do
		wait(.1)
		print("Blocking")
	end
end)

I already deleted all of the assets for blocking, thanks for trying to help though

You can still access it by going to the version history of your place and opening an older version.

You forget to add Value property, it should look like this:

task.wait(1) -- waiting for character to load
local character = script.Parent.Parent.Parent
while script.Parent.Blocking.Value do
    print("hey")
    task.wait(0.1)
end

EDIT: correction