Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ObjectValue not firing .Changed event?

Asked by 1 year ago

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.

0
Can you show the updateParty() function in the client? I’m curious. T3_MasterGamer 2189 — 1y

1 answer

Log in to vote
1
Answered by
lamgogo 56
1 year ago
Edited 1 year ago

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

Ad

Answer this question