Why Can't I access a value from a bool but can access another value from another bool from (almost) the same path?

Can someone help me on why is this script not working?

enableInteractions & playerInRange are both BoolValue

i can access and change playerInRange but can’t access or detect if the enableInteractions value is changed or not.

Thanks for the help in advance :slight_smile: !

This in the PlayerCollideHandler (its a Script)

local collider = script.Parent
local npc = collider.Parent

local playerInRange = collider.playerInRange
local enableInteractions = npc.enableInteractions
local npcID = npc.npcID

local function onTouched()

	if enableInteractions.Value then
		
		playerInRange.Value = true
		
	end
	
end

local function onTouchEnded()
	
	playerInRange.Value = false
	
end

collider.Touched:Connect(onTouched)
collider.TouchEnded:Connect(onTouchEnded)

Located Here

Location

Try one of the following
if value.Value == true
if value then

I already tried it but its still not working :frowning: .

Are there any errors? Maybe your part is unanchored. Try putting prints in your code to tell where it stops.

no errors at all, i can even access the other boolvalue, but this particular one isn’t working.

I think I see the issue. You never set the value of enableInteractions in your script! Unless you have another script settting the value.

its a ‘BoolValue’ which is turned on and off but it isn’t affecting my script at all, like if its on, then it should change the playerInRange, which it does. But then turning it off in-game, it doesn’t stop affecting playerInRange.

Can you please try to print everything so we can see where it stops.

it just simply doesn’t, there are no errors.

So the Touched(Ended) events aren’t firing?

Try close Roblox Studio and reopen it similar thing happened to me but fixed after restarting it

When enableInteraction’s value is true as I start the game, it behaves like its true the whole time even if I turn it off in-between. It should stop turning playerInRange’s value to true if its turned off in-game, which is not happening.

Try to use while/RunService loop and check magnitude instead.

I tried it, but its not working, I even created a new place and scripted it. But its still not working.

Maybe try setting the values to true outside of the touched events. Include .Changed or :GetPropertyChangedSignal()

Well, the code is in a script, not a local script so I can’t use RunService and a while loop for something like this is just a waste of resources.

I tried .Changed and it its detecting the change either. Let me try :GetPropertyChangedSignal().

1 Like

Why you don’t use local script then? And you can use RunService in normal Script but without .RenderStepped event.

Changing values on the client wouldn’t register on the server. Unless OP wants to write RemoteEvents.

For some reason this won’t work with bool values, try instead:

if enableInteractions == true then

It’s strange why you can’t access it using .Value can you try and change all code in the script which involves bool values to if boolvalue == true/false.

1 Like