Hello, I am new to roblox studio and I am trying to build a SAO (sword art online) type RPG. I am trying to setup Mob to be a script base for my monsters. It is good and works except that I can't find out how to make it deal damage to me. I am not sure if it is something wrong with the Mobs attack, weapon, or something like that. I took the setup Mob from: Ultimate RPG Starter Kit v.14.2 by Kitteh6660 At first the Mod could deal damage to me and move around normally, but I couldn't damage it. So I changed the Mod from human to Humanoid so my sword could deal damage to it, and it worked but now it won't deal damage to me.
This is what my Mobmanager script looks like. If there is any information you need I can send it to you. Thank you, Peanutthedestoyer
local Module = require(Game.ServerScriptService.MobFunctions)
local larm = script.Parent:FindFirstChild("Left Arm")
local rarm = script.Parent:FindFirstChild("Right Arm")
local Debounce = false
local OrigPos = script.Parent.Torso.Position
LinkedSword = nil
TicksUntilWander = 0
script.Parent.Name = script.Parent.SETTINGS.MobName.Value .. " [" .. script.Parent.SETTINGS.Lvl.Value.. "]"
script.Parent.Humanoid.Health = script.Parent.Humanoid.MaxHealth
--Damage on hit.
function DamagePlayer(Hit)
if Hit.Parent:FindFirstChild("Humanoid") ~= nil and script.Parent.Humanoid.Health > 0 then
if Debounce == false then
Debounce = true
Module.AttackPlayer(script.Parent, Hit.Parent:FindFirstChild("Humanoid"), script.Parent.SETTINGS.MinDmg.Value, script.Parent.SETTINGS.MaxDmg.Value, script.Parent.SETTINGS.HitChance.Value, script.Parent.SETTINGS.CritChance.Value, script.Parent.SETTINGS.CritMagnitude.Value)
wait(script.Parent.SETTINGS.CooldownMagnitude.Value/100)
Debounce = false
--else print("Debouncing")
end
else
return false
end
end
function RegisterTool(tool)
if tool:IsA("Tool") then
LinkedSword = tool
LinkedSword.Handle.Touched:connect(DamagePlayer)
end
end
larm.Touched:connect(DamagePlayer)
rarm.Touched:connect(DamagePlayer)
script.Parent.ChildAdded:connect(RegisterTool)
--XP and Gold on death.
function Died()
local tag = script.Parent.Humanoid:FindFirstChild("creator")
if tag ~= nil then
if tag.Value ~= nil then
local Leaderstats = tag.Value:FindFirstChild("leaderstats")
if script.Parent.SETTINGS:FindFirstChild("XP") ~= nil and script.Parent.SETTINGS:FindFirstChild("Gold") ~= nil then
Module.AddStats(Leaderstats, script.Parent.SETTINGS.XP.Value, script.Parent.SETTINGS.Gold.Value)
else
print("Can't find XP and Gold!")
end
end
end
if script.Parent:FindFirstChild("Model") ~= nil then
if script.Parent.Model:FindFirstChild("Part") ~= nil then
script.Parent.Model:Destroy()
end
end
end
script.Parent.Humanoid.Died:connect(Died)
--Spawn initial part for purpose of returning. The purpose of this is to fix the wander as they move in straight line unintentionally.
if script.Parent:FindFirstChild("Model") == nil then
model = Instance.new("Model", script.Parent)
part = Instance.new("Part", model)
part.Anchored = true
part.CanCollide = false
part.Transparency = 1
part.Position = OrigPos
end
--Follow
function findNearestTorso(pos)
local list = Game.Workspace:GetChildren()
local torso = nil
local dist = script.Parent.SETTINGS.ChaseRange.Value
local temp = nil
local Humanoid = nil
local temp2 = nil
for x = 1, #list do
temp2 = list[x]
if (temp2.className == "Model") and (temp2 ~= script.Parent) then
temp = temp2:FindFirstChild("Torso")
Humanoid = temp2:FindFirstChild("Humanoid")
if (temp ~= nil) and (Humanoid ~= nil) and (Humanoid.Health > 0) and (script.Parent.Torso.Position - OrigPos).magnitude <= script.Parent.SETTINGS.ChaseDistance.Value then
if (temp.Position - pos).magnitude < dist then
torso = temp
dist = (temp.Position - pos).magnitude
end
end
end
end
return torso
end
while true do
wait(0.2)
--Chase
local target = findNearestTorso(script.Parent.Torso.Position)
if target ~= nil then
script.Parent.Humanoid:MoveTo(target.Position, target)
end
--Wander
if TicksUntilWander > 0 then
TicksUntilWander = TicksUntilWander - 1
else
TicksUntilWander = math.random(10, 25)
if target == nil then
if script.Parent:FindFirstChild("Model") ~= nil then
script.Parent.Humanoid:MoveTo(Vector3.new(OrigPos.X + math.random(- script.Parent.SETTINGS.WanderRadius.Value, script.Parent.SETTINGS.WanderRadius.Value), OrigPos.Y, OrigPos.Z + math.random(-script.Parent.SETTINGS.WanderRadius.Value, script.Parent.SETTINGS.WanderRadius.Value)), script.Parent.Model:FindFirstChild("Part"))
end
end
end
end

5 comments
so he knows how to use the code block format but ignores it when putting his script in?
Please remember that the code-block should be used on 'code'! Thanks!
You won't be able to get help until you properly format your code.
sry about that XP
I had no idea I was even able to do that. So thank you luke,DigitalVeer, and Programmix for pointing it out. :)