i’m trying to make a punch move.
the way i do this is by checking in a localscript when E is pressed and then firing a remote event
in the serverscript i clone a part and make a weld and put the part infront of the player
then when the part gets hit i make the person who got hit take damage
but for some reason when i try to hit myself in a local server there’s only like a 5% chance it works
on a dummy it works fine but when i try to do it on myself it doesn’t
i have tried to check if the hit.parent was a model but that didn’t work
localscript inside of StarterPlayerScripts:
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local event = game.ReplicatedStorage.Events.Event
UIS.InputBegan:Connect(function(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.E then
event:FireServer()
end
end)
serverscript inside of serverscript service:
local event = game.ReplicatedStorage.Events.Event
local poepleHit = {}
event.OnServerEvent:Connect(function(player)
local hitbox = game.ReplicatedStorage.HitBoxes.Part:Clone()
local weld = Instance.new("Weld")
hitbox.Parent = game.Workspace
weld.Parent = player.Character.HumanoidRootPart
weld.Part0 = weld.Parent
weld.Part1 = hitbox
weld.C1 = weld.C0 - weld.C0.Position + Vector3.new(0, 0, 3)
hitbox.Touched:Connect(function(hit)
local damage = 5
if hit.Parent ("Humanoid") and not table.find(poepleHit, hit.Parent) then
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - damage
table.insert(poepleHit, hit.Parent)
end
end)
wait()
hitbox:Destroy()
table.clear(poepleHit)
end)