Hi! I was wondering if is posible to make Custom :Function(). For example:
function :ChangeColor(color)
self.BrickColor = color
end)
--Script
part:ChangeColor("Red")
part would change its color to red.
function :AllowFalldamage()
if self:IsA("Humanoid") then
<FallDamageCode>
end
end
-- Script
game.Players.PlayerAdded:Connect(function(plr)
plr.Character.Humanoid:AllowFalldamage()
end)
Player when will fall Down he will get damage
Metatables must be the thing you are looking for!
1 Like
wevetments
(wevetments)
October 23, 2022, 7:18am
#3
I believe this is what you mean
ALL ABOUT OOP!
Prerequisites
An understanding of meta-tables (although the required code will be explained)
How tables work and a competent grasp of the Lua syntax
Parts
What is OOP?
How does it help me?
How do I make this work in Lua?
Integrating with module scripts
What about inheritance?
What is OOP?
OOP stands for Object Orientated Programming and is a way of laying out code in a more friendly way whilst also keeping large projects organised. You have used objects in pro…
Kobbly99
(Kon)
October 23, 2022, 7:23am
#4
Adding a custom function to an instance might be a hard thing to do. You might as well try to replace it with function inside the script.
function ChangeColor(Part,Color)
Part.BrickColor = Color
end
ChangeColor(Part,"Red")
Although this is only a suggestion, we cannot say that its impossible to add a custom :Function()
1 Like
system
(system)
Closed
October 2, 2023, 2:54pm
#5
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.