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

how to fix this damage script not working?Touched is not a valid member of part

Asked by
hokyboy 270 Moderation Voter
4 years ago
local RepStorage = game:WaitForChild("ReplicatedStorage")
local Remote = RepStorage:WaitForChild("Stomp")



Remote.OnServerEvent:Connect(function(player)
    local Character = player.Character
    local Foot = Character.RightFoot
    local Postion = Foot.Position
    local Hitbox = Instance.new("Part",Foot)
    Hitbox.Size = Vector3.new(.2, 15, 15)
    Hitbox.Transparency = 0
    Hitbox.Position = Postion
    Hitbox.Orientation = Vector3.new(0,0, -90)
    Hitbox.BrickColor = BrickColor.new("Really red")
    Hitbox.Anchored = true
    Hitbox.CanCollide = false
    Hitbox.Shape = "Cylinder"
    print("Event Finished")

    Hitbox:Touched(function(hit)
        if not hit.Parent:FindFirstChild("Humanoid") then return end
            if hit.Parent.Name ~= Character.Name then
                hit.Parent:FindFirstChild("Humanoid"):TakeDamge(36)
                wait(2.5)
                Hitbox:Destroy()
        end
    end)
end)

Output error: Touched is not a valid member of part

1
Touched is not a function, it is a event. So instead of Hitbox:Touched(function(hit), you should do like this Hitbox.Touched:Connect(function(hit) Block_manvn 395 — 4y

Answer this question