.Changed Signal not working in Server Script

I’m not sure why, but I cant get anything from .Changed in a server sided script, The property in the Bool Value is being changed to true, but the script isnt detecting that. I have a print setup right after the bool.changed function but nothing prints. Below Is the script that sets the bool to be true, and the script that detects the change.

Setting the Bool (Server)

local rs = game:GetService("ReplicatedStorage")
local plants = rs:WaitForChild("Plants")
local event = rs.Plants.PlantEvent
local seeds = plants:WaitForChild("Seeds")

script.Parent.Triggered:Connect(function(plr)
	if script.Parent.Parent.Planted.Value == false and script.Parent.Parent.Tilled.Value == true then
		plr.PlayerGui.Menus.PlantSeed.Visible = true
	end	
end)

event.OnServerEvent:Connect(function(plr, plant)
	if plr.stats[plant].Value >= 1 then
		local clone = seeds:FindFirstChild(plant):Clone()
		clone.Parent = script.Parent.Parent
		script.Parent.Parent.Planted.Value = true
		plr.stats[plant].Value -= 1
		clone:FindFirstChild("Growing").Value = true
		script.Parent.Enabled = false
		plr.PlayerGui.Menus.PlantSeed.Visible = false
		
	end
end)

Script for detecting the change (Server)

local tweenService = game:GetService("TweenService")


script.Parent.Growing.Changed:Connect(function()
	print("test1")
	if script.Parent.Growing.Value == true then
		print("test2")
		for i, v in pairs(script.Parent:IsA("Part")) do
			print("test3"..v)
			local tweenInfo = TweenInfo.new(5, Enum.EasingStyle.Linear)
			local goal = {Size = Vector3.new(0.125, 4, 0.125)}
			local tween = tweenService:Create(v, tweenInfo, goal)
			tween:Play()
		end
	end
end)

Any help is appriciated, I’ve only ever used .Changed in LocalScripts.

Hierarchy
image

I suspect you need to reference the Value itself in this line:

script.Parent.Growing.Changed:Connect(function()
-- should be
script.Parent.Growing.Value.Changed:Connect(function()

That gives the error “attempt to index boolean with ‘Changed’”. The only time I’ve used .Changed is in the making of currency display UI, which would be something like player.leaderstats.coins.Changed:connect. I dont think checking the value works in any senario.

Yes you need to reference the .Value but for booleans don’t use .Changed instead do

script.Parent.Growing:GetPropertyChangedSignal("Value"):Connect(function()
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.