Value.Changed currently not working as expected

I was trying to make a system that runs code when a value is changed to a specific thing. After finding errors, I commented out the script to run and just put print("Value was changed") This still seems to not be working. Everything else in this code prints except for the fact that the value is being changed. Everything is spelled correctly, and I even looked at status.roblox.com. Can somebody please explain why this function isn’t being run? I also tried it without the newValue parameter in the Changed I’m also on the Grapejuice Roblox Studio Emulator but that shouldn’t be the problem

Here's the script
local Materials = {
	Enum.Material.Brick,
	Enum.Material.Cobblestone,
	Enum.Material.Concrete,
	Enum.Material.CorrodedMetal,
	Enum.Material.DiamondPlate,
	Enum.Material.Fabric,
	Enum.Material.Foil,
	Enum.Material.ForceField,
	Enum.Material.Glass,
	Enum.Material.Granite,
	Enum.Material.Grass,
	Enum.Material.Ice,
	Enum.Material.Marble,
	Enum.Material.Metal,
	Enum.Material.Neon,
	Enum.Material.Pebble,
	Enum.Material.Plastic,
	Enum.Material.Sand,
	Enum.Material.Slate,
	Enum.Material.SmoothPlastic,
	Enum.Material.Wood,
	Enum.Material.WoodPlanks 
}

print("Part Spawner is being run")
print(game.ReplicatedStorage.Name)
local creatingPartsObject = game.ReplicatedStorage:WaitForChild("CreatingParts")
print("Done waiting for child")
game.ReplicatedStorage.CreatingParts.Changed:Connect(function(newValue)
	print("Value was changed")
	--[[
	if game.ReplicatedStorage.CreatingParts.Value == true then
		print("Value is true")
		while wait(.5) do
			print("Started Loop")
			local part = game.ServerStorage:WaitForChild("Part"):Clone()
			part.Parent = game.Workspace.Parts
			part.Position = Vector3.new(math.random(-250,250),10,math.random(-250,250))
			local randomMaterial = math.random(1,#Materials)
			part.Material = Materials[randomMaterial]
			part.Color = Color3.new(math.random(1,255),math.random(1,255),math.random(1,255))
		end
	end
	--]]
end)
print("Script finished")
Here's the game file

The script is called PartSpawner and it’s in ServerScriptService
PartSpawnerError.rbxl (30.5 KB)

What I’m looking for as a response

I would be looking for the following:

  1. Studio or live game (or both) tests done

  2. How you found the answer (Did you change any code? Was this working for you and my Studio’s just acting weird?)

Is this a server or local script? How and where did you change the value? Did you test it in live game or studio?

@Quwanterz It is a server script. I was changing the value manually. I don’t have live game on this computer to test it, but that shouldn’t affect results. Feel free to look at the game file if you need further information.

When I say live game, I mean joining the game via the website.

What do you mean by “manually”? Are you changing it via the server side or client side?

@Quwanterz I don’t have Roblox Player and can’t install it on Linux I don’t believe (Using different computer from normal, would normally have Windows 10 and Player) I realized the issue:
I was changing the value on the client side, just figured out because of your question that it needs to be server-sided. Thanks for the help.

2 Likes

I was checking the game file, you were trying to change the Values with a localscript, if you want to get local stuff for example pressing the button use remote events.

That’s nice to hear. You can now make a post be the solution so others know that it is solved! Not a requirement, but it’s a great reminder.

Oh sorry I didn’t realize you posted this. My bad.