How can I get the last value of an object value?

So lets get straight to it.

I have a network ownership system that uses an object value that has the player’s name as a value. When the value changes to another player’s name, I want to get the last value (last player’s name)

Any help would be appreciated, thanks!

2 Likes

Any help on this? I have looked at the developer hub and some YouTube videos and I still can’t find the solution.

just make a script assigning the original name as the attribute, if its an object value;

script.Parent:SetAttribute(script.Parent.Value.Name)

im pretty sure if you assign it the player instance you can just pick up the name from the value

1 Like
local currentOwner = instance.new("ObjectValue")
local previousOwner = instance.new("ObjectValue")

local function SetOwner(player)
    previousOwner.Value = currentOwner.Value
    currentOwner.Value = player
    script.Parent:SetNetworkOwner(player)
end
2 Likes

Thanks! I was just wondering If i could check if both of the value’s (the player’s name) are on the same team, so I can award the old object value owner a leaderstat.

Code:

local old = ball.OldOwner.Value
	local new = ball.Owner.Value
	if player.Name == old and player.TeamColor == new.TeamColor then
		print("We got a lucky winner!")
	end

i think so just do Instance:GetAttribute(“AttributeName”) as thats the “value”

oh, i changed from using an attribute to using a new value (new value)