Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

ObjectValue not firing .Changed event?

Title. ObjectValue is created on server and sent to client. The listener in the client is not firing as expected:

CLIENT

assignPartyObject.OnClientEvent:Connect(function(partyObject)
	
	print("Assigned a party object")
	
	party = partyObject
	
	party.Changed:Connect(function()
		print("Party changed to " .. party.Value.Name)
		party.Value.ChildAdded:Connect(updateParty)
		party.Value.ChildRemoved:Connect(updateParty)
	end)
	
end)

SERVER

players.PlayerAdded:Connect(function(addedPlayer)
	local addedPlayerPartyObject = Instance.new("ObjectValue")
	addedPlayerPartyObject.Parent = addedPlayer
	addedPlayerPartyObject.Name = "Party"
	
	assignPartyObject:FireClient(addedPlayer, addedPlayerPartyObject)
end)

The server then changes the value of the ObjectValue.

reciever:WaitForChild("Party").Value = party

I am 100% certain that the property is being changed. I can see it in the properties tab under explorer and scripts can access the new and old values. The only thing that isn't working is that the listener is not firing.

The print statement fires and no warnings or errors are printed. Can someone explain what kind of black magic this is? I've tried all sorts of weird tests and haven't closed in on a solution. I'll respond quickly to any questions

I'm wondering if it has something to do with the .Changed listener being nested inside that remote listener, but I don't know why that would be. Making my own listener on a clock works perfectly, but this is disgusting practice and it makes my eyes bleed so I'd rather figure out what's wrong here.

1 comment

0

Can you show the updateParty() function in the client? I’m curious.

1 answer

✓ Accepted answer

So there is a funni thing that value.changed rarely work,idk how but it never work for me,even using both local or server script(hey ROBLOX, its useless so remove it or fix it lol) instead use the Value:GetPropertyChangedSignal("Value") it works all the time so this is the complete script in ur cilent script:

assignPartyObject.OnClientEvent:Connect(function(partyObject)

    print("Assigned a party object")

    party = partyObject

    party:GetPropertyChangedSignal("Value"):Connect(function()
        print("Party changed to " .. party.Value.Name)
        party.Value.ChildAdded:Connect(updateParty)
        party.Value.ChildRemoved:Connect(updateParty)
    end)

end)

there is no other errors in ur script btw if it doesnt work tell me

This discussion is preserved as it was. New answers, comments, and votes are closed.