Hi, I've been trying to get this script working for ages but I can't seem to even though the task that I'm trying to achieve seems very simple. So I have a TextButton in StarterGui and when it's clicked it changes a NumberValue, which is stored in the workspace. It is successfully changing the value of the number value in the workspace but in my scripting, it isn't working. I'm sure I've written the script wrong so any advice would help me a lot.
Here is my script:
-- PlowedDirt is the name of a part that I'm storing in ServerStorage
game.Workspace.Value.Changed:connect(function(NewValue)
Value2 = NewValue.Value
end)
local value = 0
local function clicked(player)
if value == 0 and Value2 == 1 then
local replacement = game.ServerStorage.PlowedDirt:Clone()
replacement.Parent = script.Parent
replacement.Position = script.Parent.Position + Vector3.new(0,0.1,0)
value = 1
end
end
script.Parent.ClickDetector.MouseClick:Connect(clicked)

3 comments
any errors in output or, have you used print to see at what line the error is occurring?
I think the problem is that the script isent detecting when the values are changed for example I have a Number Value in the workspace and when I click a GUI it updates the value to 1 but in my script it continues to print that the value = 0 :/
That is because of filtering enabled. You will need to use remote events.