function Player:IsAliveHumanoid()
local character = self.Character
if character == nil then return false end
if character:FindFirstChild("Humanoid") and character:FindFirstChild("HumanoidRootPart") then
return character.Humanoid.Health > 0
end
return false
end
Player:IsAliveHumanoid()
Also yes, it’s possible, you just have to follow the tutorial that @DecodedString just put.
For properties, you can do that too, you just have to treat it like a function, but it wouldn’t be.
I did. Did you even read @DecodedString 's reply? I added alternative ways for values, as you did say
“values” as well. And as @Obj_ective states, you can do more using metatables if desired.
function Player:IsAliveHumanoid()
local character = self.Character
if character == nil then return false end
if character:FindFirstChild("Humanoid") and character:FindFirstChild("HumanoidRootPart") then
return character.Humanoid.Health > 0
end
return false
end
local Player = {}
Player.__index = Player
function Player.new(player)
return setmetatable({
_player = player
}, Player)
end
function Player:IsAliveHumanoid()
local character = self._player.Character
if character == nil then return false end
if character:FindFirstChild("Humanoid") and character:FindFirstChild("HumanoidRootPart") then
return character.Humanoid.Health > 0
end
return false
end
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
local customPlayer = Player.new(player)
print(customPlayer:IsAliveHumanoid())
end)
It might not be the best approach, but it should work.
Also, if you haven’t already, take a look at @Mega_Hypex & @RuizuKun_Dev 's work in this post of
the thread that @DecodedString provided:
You can get as fancy as you want but you need to really study the metatable metamethods and get
a clear understanding of how they work. So for instance you could make a wrapper / subclass that
would let you use the dot index notation but under the hood it would be using SetAttribute(), which
also could let you “rewrap” an Instance object later, and be able to “re-access” those attribues by
dot indexing them. Not that I recommend doing this, but you could.
Note: As @anthropomorphic_dev was stating, the Roblox Instance metatables are locked, therefore
we have to do this one-step-away with wrapping to accomplish adding custom values/functions.