RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"sword slash with animation and particle that deals damage and activates when you click a tool"
-- local script local tool = script.Parent local slashParticle = script.Parent.SlashParticle local slashSound = script.Parent.SlashSound function onActivated() tool.Animate.SlashAnim:Play() slashParticle:Emit(1) slashSound:Play() -- make a ray from the tool's position to the mouse's position local ray = Ray.new(tool.Position, (mouse.Hit.p - tool.Position).unit * 10) -- check if the ray hits a humanoid local hit, pos, norm = workspace:FindPartOnRayWithIgnoreList(ray, {tool, tool.Parent}) if hit and hit:IsA("Humanoid") then -- deal damage to the humanoid hit.Health = hit.Health - 10 end end tool.Equipped:Connect(onActivated)