How do I get a Bool value to change through touch event?

So I am trying to change a bool value from false to true when a player walks through an invisible part. For context, setting this value as true triggers a series of scripted events necessary to progress the experience. But it doesn’t seem like a standard touch event script that I’d use for everything else is working…

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		wait(1)	
		game.Workspace.Values.Warning = true
	end
end)

( I’m a beginning developer and learned this from some tutorial or something, I don’t remember )

What am I doing wrong here? Or should I use a different method entirely?

What is the Instance Warning, what are Values? Are there errors in the output tab?
Example how:

Local b = false
script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and b ~= true and b ~= nil then
	b = true	
Game.Workspace.Values.Warning.CanCollide == false -  assuming Warning is a part
	end
end)

You’re missing a .Value at the end of .Warning. When changing a bool value, you’re usually looking to change the value property, however in the code you must specify that you’re trying to set the value to true, rather than the instance itself.

Give workspace.Values.Warning.Value = true a shot.

Okay so, “Warning” is the actual bool value I’m trying get to change from true to false and “Values” is just the folder of other values it belongs in.

There is one output error which reads Warning is not a valid member of Folder “Workspace.Values”. This doesn’t make sense to me, because Warning is very clearly in workspace.Values

May I see the folder and all the children inside it? Is Warning properly parented to Values? Make sure to add .Value at the end of Warning. To run it properly too.

Oh my gosh, I can’t believe I forgot about that this whole time. I did it for every other value script I had! It’s always the obvious things with me.
Thanks for letting me know this quick.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.