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

Checking the value of a bool value inside a ontouched function?

The script fires if I remove the and bool.Value == false and it prints but I need to CHECK the value, any reason why it doesn't work?

local bool = script.Parent.Parent.IsZapping
bool.Value = false



function onTouched(Obj)
	local h = Obj.Parent:FindFirstChild("Humanoid")
	if h and bool.Value == false then
		print("Worked")
	end
end

script.Parent.Touched:Connect(onTouched)

Discord: Unknown Intelligence#6569

2 comments

0

Is the value actually changing to false? You should check and see.

0

You might be able to remove the .Value but I’m not sure. I always forget with bool values.

1 answer

script.Parent.Touched:Connect(function()
	local bool = script.Parent.Parent.IsZapping
	if bool.Value == false then
		print("worked")
	end
end)

You don't need to check for a Humanoid. The player who is touching is already defined while the function is running.

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