local o=(game:GetService("\082\117\110\083\101\114\118\105\099\101")):IsServer()local S=require(script.Parent.Parent.Signal)local T={}T.__index=T function T.new(i)assert(not o,"\067\108\105\101\110\116\082\101\109\111\116\101\080\114\111\112\101\114\116\121 \099\097\110 \111\110\108\121 \098\101 \099\114\101\097\116\101\100 \111\110 \116\104\101 \099\108\105\101\110\116")local k=setmetatable({_object=i;_value=nil;_isTable=i:IsA("\082\101\109\111\116\101\069\118\101\110\116")},T)local function W(o)k._value=o end if k._isTable then k.Changed=S.new()k._change=i.OnClientEvent:Connect(function(o)W(o)k.Changed:Fire(o)end)W(i.TableRequest:InvokeServer())else W(i.Value)k.Changed=i.Changed k._change=i.Changed:Connect(W)end return k end function T.Get(o)return o._value end function T.Destroy(o)o._change:Disconnect()if o._isTable then o.Changed:Destroy()end end return T



local IS_SERVER = game:GetService("RunService"):IsServer()
local Signal = require(script.Parent.Parent.Signal)

local ClientRemoteProperty = {}
ClientRemoteProperty.__index = ClientRemoteProperty


function ClientRemoteProperty.new(object)

	assert(not IS_SERVER, "ClientRemoteProperty can only be created on the client")

	local self = setmetatable({
		_object = object;
		_value = nil;
		_isTable = object:IsA("RemoteEvent");
	}, ClientRemoteProperty)

	local function SetValue(v)
		self._value = v
	end

	if self._isTable then
		self.Changed = Signal.new()
		self._change = object.OnClientEvent:Connect(function(tbl)
			SetValue(tbl)
			self.Changed:Fire(tbl)
		end)
		SetValue(object.TableRequest:InvokeServer())
	else
		SetValue(object.Value)
		self.Changed = object.Changed
		self._change = object.Changed:Connect(SetValue)
	end

	return self

end


function ClientRemoteProperty:Get()
	return self._value
end


function ClientRemoteProperty:Destroy()
	self._change:Disconnect()
	if self._isTable then
		self.Changed:Destroy()
	end
end


return ClientRemoteProperty
