Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

When i add anchored is true its not giving damage?

Asked by 5 years ago

When i add part.Anchored = true, its not activating the part.Touched thing or something idk. But when i remove the part.Anchored = true, its now giving damage. How do i true the anchor and give damage? What is the problem?

local Attack = true

script.Parent.Activated:Connect(function()
wait(0.1)

if Attack == true then      
Attack = false  
local character = script.Parent.Parent
local Humanoid = character:WaitForChild('Humanoid')
local torso = character:WaitForChild('HumanoidRootPart')

local part = Instance.new("Part", game.Workspace)
    part.Size = Vector3.new(7.3, 4 ,3)
    part.Anchored = true
    part.CanCollide = false
    part.Transparency = 0.5
    part.CFrame = torso.CFrame+(torso.CFrame.lookVector*3)


    part.Touched:Connect(function(p)
        local hum = p.Parent:FindFirstChildOfClass("Humanoid")

        if p.Parent.Name == ("Mob") then
            if script.Parent.CanDamage.Value == true then
                script.Parent.CanDamage.Value = false
                hum:TakeDamage(20)
                wait(0.5)
                script.Parent.CanDamage.Value = true
            end


        end


    end)


wait(0.15)
part:Destroy()
wait(0.5)
Attack = true   

end

end)
0
Is this from an NPC? MinuhaYT 19 — 5y
0
Nah, its players script. When players use this tool this happens. aSpecialGuy 18 — 5y
0
Is this script placed in the Handle of the tool? MinuhaYT 19 — 5y
0
Nah not in the handle, its parent is tool. aSpecialGuy 18 — 5y
View all comments (2 more)
0
Are you doing hit detection by making a part? mistrustfully 0 — 5y
0
Yeah, im creating a part front of the character and then doing these things. And one more problem, i want to hit all the mobs who is in the part but it just damage one of them. How do i make the multiple damage? aSpecialGuy 18 — 5y

Answer this question