Rep.Events.Combat.OnServerEvent:Connect(function(Player, Action)
if Action == "Light" then
local hit = false
local Character = Player.Character or Player.CharacterAdded:Wait()
local Hitbox = game:GetService("ServerStorage").Hitbox:Clone()
Hitbox.Parent = workspace
local offset = Vector3.new(0,0,-2)
Hitbox.CFrame = Character.HumanoidRootPart.CFrame*CFrame.new(offset)
wait(.15)
Hitbox.Parent = nil
Hitbox.Touched:Connect(function(Touched)
if not hit and not Touched:IsDescendantOf(Player.Character) and Touched.Parent:FindFirstChild("HumanoidRootPart") then
hit = true
Touched.Parent:FindFirstChild("Humanoid"):TakeDamage(10)
FX.Parent = workspace
FX.CFrame = Touched.Parent.HumanoidRootPart.CFrame*CFrame.new(math.random(-10,5)/15,math.random(-10,5)/15,math.random(-10,5)/15)
end
end)
wait(.2)
FX.Parent = nil
end
end)
COMMUNITY QUESTION
Why aren't players taking damage from the Hitbox even when it spawns on them?
1 answer
You are using the touched function which only works when the player actually moves around. To fix this you can instead make the hitbox continously search for players inside of it and deal damage to them refer to this for more help https://devforum.roblox.com/t/how-do-you-check-if-the-player-is-in-certain-area/121163/11
This discussion is preserved as it was. New answers, comments, and votes are closed.
