1. What do you want to achieve? Keep it simple and clear!
I am trying to make a punch script.
2. What is the issue? Include screenshots/videos if possible!
The damage script is completely not working
3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried using magnitude and touched events.
edit:
I’ve been trying to make a damage script for my punch script through a remote event and its not working. I’ve tried Magnitude and touched events for my character’s hands, feet, arms, and legs, but none seem to work. It is an animation based script. (The reason why I am using pcalls is because I keep getting these annoying errors saying stuff about the animation and how it is my friends animation.)
Animation "https://assetdelivery.roblox.com/v1/asset?id=4149415551&serverplaceid=0" failed to load in "Animation.AnimationId": Animation failed to load
local HitSound = {'1693499499'}
local MissSound = {'1489705211'}
local start = 'http://roblox.com/asset/?id='
local start2 = 'rbxassetid://'
game.ReplicatedStorage.Events.AttackPunch.OnServerEvent:Connect(function(Player)
local p = pcall(function()
local UsedPunchId = PunchAnimationIDS[math.random(1, #PunchAnimationIDS)]
local UsedHitId = HitSound[math.random(1, #HitSound)]
local Animation = Instance.new("Animation")
Animation.AnimationId = start2..UsedPunchId
local ANIM = Player.Character.Humanoid:LoadAnimation(Animation)
ANIM:Play()
game.Debris:AddItem(Animation,3)
local MissHit = Instance.new("Sound",Player.Character.HumanoidRootPart)
MissHit.SoundId = start2..MissSound[math.random(1, #MissSound)]
MissHit:Play()
game.Debris:AddItem(MissHit, 10)
for _, v in next(Player.Character:GetChildren()) do
if v.Name:match('Arm') or v.Name:match('Hand') or v.Name:match('Foot') or v.Name:match('Leg') then
v.Touched:Connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild('Humanoid') then
local HitSound = Instance.new("Sound",Player.Character.HumanoidRootPart)
HitSound.SoundId = start2..HitSound[math.random(1, #HitSound)]
HitSound:Play()
MissHit:Pause()
game.Debris:AddItem(MissHit, 0.0001)
game.Debris:AddItem(HitSound, 10)
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 8
print('hit boi finally')
end
end)
end
end
end)
end)```
It is fired from the local player.