Jump to content

Get percentused from client side


Recommended Posts

I've been digging around inventoryitem_replica and inventoryitem_classified to get a trap's percent usage, but I just can't figure for my life how to do this.

This is what I've been doing:

	local items = player.replica.inventory:GetItems()
	local trap = nil
	
	for i,v in ipairs(items) do
		if v.prefab == "trap" then
			print(v.replica.inventoryitem.percentused)
			print(v.components.inventoryitem)
			
			trap = v
			--break
		end
	end

Can anyone familiar with client side stuff point me in the right direction?

Link to comment
Share on other sites

4 hours ago, Ryuushu said:

I've been digging around inventoryitem_replica and inventoryitem_classified to get a trap's percent usage, but I just can't figure for my life how to do this.

This is what I've been doing:


	local items = player.replica.inventory:GetItems()
	local trap = nil
	
	for i,v in ipairs(items) do
		if v.prefab == "trap" then
			print(v.replica.inventoryitem.percentused)
			print(v.components.inventoryitem)
			
			trap = v
			--break
		end
	end

Can anyone familiar with client side stuff point me in the right direction?

local items = player.replica.inventory:GetItems()
local trap = nil
	
for i,v in ipairs(items) do
	if v.prefab == "trap" then
		local percentusedcomponent = v.components.finiteuses
		print(percentusedcomponent:GetPercent())
		trap = v
	end
end

 

Link to comment
Share on other sites

32 minutes ago, Ryuushu said:

@zUsername

That works on the server side, but if you try to run it as a client you'll crash (finiteuses = nil) since you can't access the components directly, it has to be through a replica. Still, thank you.

local items = player.replica.inventory:GetItems()
for i,v in ipairs(items) do
	if v.prefab == "trap" then
		print(v.replica.inventoryitem.classified.percentused:value())
	end
end
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...