Script not detecting if value

As the title states. I tried doing Turned.Changed function but it wasn’t working either.

The code:

local play = true
local debounce = false
local Turned = game.ReplicatedStorage.Turned


while play do
	task.wait()
	if game.ReplicatedStorage.Turned.Value == true then
		if not debounce then
			debounce = true
			script.Parent.BrickColor = BrickColor.new("Dark green")
			game.ReplicatedStorage.Temp.Value += 1
			task.wait(1)
			debounce = false
		end
	else
		script.Parent.BrickColor = BrickColor.new("Really red")
	end
end

game.ReplicatedStorage.Turned:GetPropertyChangedSignal("Value"):Connect(function(TheChangedValue)
print(TheChangedValue)
end)

This doesn’t work for me.

This text will be blurred

I added a print(“e”) under it, and it wouldn’t print.

@Zerxiase
I am detecting it from a script inside a part inside workspace.

Are you changing the value on the Server or Client? And are you detecting the Value to be changed on the Client or Server?

Where are you changing the value? The server or client?

Not sure how to tell if it is or isnt.

Oh it’s server I think

Yup it is

You’re using a sceipt to change the value - server.
You’re using a local script to change the value - client.

Try this and tell me if it prints anything:

--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--//Variables
local Turned = ReplicatedStorage.Turned
local Part = script.Parent

--//Controls
local play = true
local debounce = false

--//Functions
local function ValueChanged()
	print("Check1")
	
	if not play then
		return
	end
	
	print("Check2")

	if Turned.Value then
		if debounce then
			return
		end
		
		print("Successful1")
		debounce = true
		
		Part.BrickColor = BrickColor.new("Dark green")
		ReplicatedStorage.Temp.Value += 1
		
		task.wait(1)
		debounce = false
	else
		print("Successful2")
		Part.BrickColor = BrickColor.new("Really red")
	end
end

ValueChanged()

Turned:GetPropertyChangedSignal("Value"):Connect(function()
	ValueChanged()
end)

“Successful one” is not working, but everything else is. Even when the value is set to true “Successful” won’t play.

Do you set the value on the client or server? You have to set it on the server for it to replicate.

I set it inside a script, which is inside a part, which is inside workspace. It is not a local script, a regular script.

I did a test with a script in server script service saying: game.ReplicatedStorage.Lightsout = true

and it wouldn’t make it true.

I then tried the same thing but a script in workspace, and it wouldn’t make it true either.

So what is wrong?

That’s a totally different value. Change that to this:

game.ReplicatedStorage.Turned.Value = true

I know, I made a new value in replicated storage, even the one you said wouldn’t work.

You should try it if you make a script in server script service or workspace.

What? I don’t get what your saying, sorry.

1 Like

I did a test with a script that was setting a value in replicated storage to true. I put that script on both workspace and server script service to test if it would work, and it wouldn’t. Neither would detecting if the value is true.

Bumping cause I still need help.

You’re not even setting the value in this block you gave…

1 Like

I made a mistake writing it here but even the correct way it does not work in studio.

The main problem of the script is that when a boolvalue turns true,

if game.ReplicatedStorage.ValueNameHere.Value == true then

that line of code won’t detect and won’t work.