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:
-
Studio or live game (or both) tests done
-
How you found the answer (Did you change any code? Was this working for you and my Studio’s just acting weird?)