Hell guys, I am Ranger, this is my first ever post. My problem is that I do not know how to create a mob that you can attack you and you can attack it. The problem is that I tried to use some of the scripts from YT but i did not understand so it would really be appreciated if you provide me with a solution. I want a script that attacks you and then you can attack it back, just like the one in islands in which you can attack it and also it can attack you. It would really help me in my game.
You’re trying to run before you can walk. Learning the basics of scripting are essential before diving into complex coding as you will at least need a basic understanding of LUA to even be able to interpret scripts.
My recommendation would be to research the things you don’t understand in separate tutorials, instead of trying to understand it without an explanation and implement it into your game.
Thank I will try my best to do it i just wanted the code since I did not find any good tutorials. well thank you for the recommendation. i wanna have some script as a reference. But thank you nonetheless
Hello, ranger_meer! Welcome to the DevForum! You might want to use a .Touched function for the attacking you script. For example.
local Damage = 20
local Damage = 20
local debouce = false
for _,v in pairs(Path_To_Model:GetChildren()) do
v.Touched:Connect(function(hit)
if not debounce then
debounce = true
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - Damage
wait(2)
debounce = false
end
end)
end
How about marking it as a Solution? Also, follow a tutorial on YouTube about “PathFindingService”, it will help you a lot with your model following you. You can also just use a free model sword, which will provide everything to damage it. As long as your model has a Humanoid, you’ll be good to go. And thank you!
You’re welcome. I hope you continue your journey with programming. It can be a very good thing to have on your resume later on when you get a job. Stay safe, happy holidays, and happy programming!