Jump to content

Recommended Posts

So i recently made a code which ups a value +1 every time you die (deathcount) and When playing on worlds without caves where im the host, it works fine. however when i host it on a world with caves where the world is being hosted off a dedicated server, it does not go up in value because it hasn't sent to all the clients in the server. i believe this is to do with netvar, however i havent dabbled into it enough to understand it, if anybody could help that would be awe some

Modmain;

Spoiler
local deathcountUI = require "/widgets/deathcounterwidget"
AddClassPostConstruct("widgets/statusdisplays", function(self)
    
self.owner.deathcounterwidget = self:AddChild(deathcountUI(self.owner, 0, 0))
end)

   

 

Widgets;

Spoiler
local widget = require "widgets/widget"
local text = require "widgets/text"

local deathcountUI = Class(widget, function(self, inst, anchor_x, anchor_y)
	self.inst = inst
	self.x = anchor_x
	self.y = anchor_y
	
widget._ctor(self, "deathcountUI") 
self.title = self:AddChild(text(BODYTEXTFONT, 33, "Death Count: ", UICOLOURS.WHITE))
self.title:SetPosition(self.x - 100, self.y + 20)
self.deaths = self:AddChild(text(BODYTEXTFONT, 33))
self.deathsval = 0
self.title:Show()
tostring(1)

inst:ListenForEvent("death", function(inst, data)
	self.deathsval = self.deathsval + 1
	self.deaths:SetString(self.deathsval)
end)

--    self:StartUpdating() 
 
self.deaths:SetString(self.deathsval)
self.deaths:SetColour(44, 0, 0, 1)
self.deaths:SetPosition(self.x + 20, self.y + 20)
end)
return deathcountUI

 

 

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
×
  • Create New...