GetPropertyChangedSignal not working

can anyone pls tell me why the value changes but the local script doesnt print?

server script:

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local MoneyPrize = 5000

Players.PlayerAdded:Connect(function(player)
	
	local LastPrizeClaim = Instance.new("IntValue",player)
	LastPrizeClaim.Name = "LastPrizeClaim"
	LastPrizeClaim.Value = 0

	RunService.Heartbeat:Connect(function()
		local character = player.Character or player.CharacterAdded:Wait()
		local HumanoidRootPart = character:FindFirstChild("HumanoidRootPart")

		local ChestZone = game.Workspace:WaitForChild("MapLayOut"):WaitForChild("VIPzone"):WaitForChild("DailyChest"):WaitForChild("ChestZone")

		if HumanoidRootPart then
			local distance = (HumanoidRootPart.Position - ChestZone.Position).Magnitude
			
			-- if a day has passed since the last claim, give rewards
			if distance < 9 and tick() - LastPrizeClaim.Value > 86400 then
				
				LastPrizeClaim.Value = tick()
				
				local Money = player:WaitForChild("leaderstats"):WaitForChild("Money")
				
				OpenSound:Play()
				Money.Value += MoneyPrize
			end
		end
	end)
	while true do
		wait(1)
		LastPrizeClaim.Value -= 1
	end
end)

local script:

LastPrizeClaim:GetPropertyChangedSignal("Value"):Connect(function()
    print()
end)

U sure it’s supposed to print absolutely nothing? I don’t think it will even show up in the studio output

1 Like

it is possible to print nothing
and i put here print() instead of the code i have

Based on the code provided, you’re creating LastPrizeClaim on the server and not parenting it to the workspace or leaderstats or anything, so it doesn’t exist on the client.

Does .Changed work? For Values it’s a negligible difference

LastPrizeClaim.Changed:Connect(function()
    print("w")
end)

image
im puting it in player

oh, my bad, totally missed that. Can you show the client-side code, how is it getting the IntValue object? Is it waiting for it to be created and sync to the client?

1 Like
print()
local player = game:GetService("Players").LocalPlayer

local LastPrizeClaim = player:WaitForChild("LastPrizeClaim")
local TimerText = script.Parent:WaitForChild("Timer"):WaitForChild("BillboardGui"):WaitForChild("TimerText")

LastPrizeClaim.Changed:Connect(function()
	print("zdfg")
	TimerText.Text = (tick() - LastPrizeClaim) / 3600
end)

i just realized that it doesnt even print the first print

1 Like

I know, but because you’re printing nothing I don’t think it will show up in the output window and so you can’t see the result

false, and it doesnt print when i put a value as well

Check the value in the explorer to see if it’s actually changing on the clientside

So is the script disabled? If that’s the whole script there is no other reason it shouldn’t run the print from the client.

Are you certain the client side script is a LocalScript that’s running? I created a simplified version of your code and it works correctly:

ServerScriptService → Script

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)

	local LastPrizeClaim = Instance.new("IntValue",player)
	LastPrizeClaim.Name = "LastPrizeClaim"
	LastPrizeClaim.Value = 0

	while true do
		wait(1)
		LastPrizeClaim.Value -= 1
	end
end)

StarterPlayer → StarterPlayerScripts → LocalScript

local Players = game:GetService("Players")

local LastPrizeClaim = Players.LocalPlayer:WaitForChild("LastPrizeClaim")
LastPrizeClaim.Changed:Connect(function(property: string)
	print(`{property} changed`)
end)
2 Likes

the problem was that i put the local script in a part instead of StarterPlayerScripts

1 Like

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