I am having with this script, the issue is that this script was originally built for R15 but I am using it for R6 I have changed "RightHand" and "LeftHand" to Right Arm and Left Arm. This script is suppose to deal damage once a player is punched but it is not dealing damage when a player is hit.

math.randomseed(tick())

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local punchEvent = Instance.new("RemoteEvent", ReplicatedStorage)
punchEvent.Name = "PunchEvent"

local animations = {867498850, 867520587} 

local function onPunchFired(plr)
	local char = game.Workspace:FindFirstChild(plr.Name)
	local humanoid = char.Humanoid
	local animation = Instance.new("Animation")
	local picked = math.random(1, #animations)
	animation.AnimationId = "http://roblox.com/asset/?id="..animations[picked]
	local animTrack = humanoid:LoadAnimation(animation)
	animTrack:Play()
	local dmgScript = script.DmgScript:Clone()
	if picked == 1 then
		dmgScript.Parent = char.Right Arm
	elseif picked == 2 then
		dmgScript.Parent = char.Left Arm
	end
	dmgScript.Disabled = false
	wait(0.4)
	dmgScript:Destroy()
end

punchEvent.OnServerEvent:Connect(onPunchFired)
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local punchEvent = ReplicatedStorage:WaitForChild("PunchEvent")

local ready = true

local function punch(inputObject, gameProcessed)
	if inputObject.KeyCode == Enum.KeyCode.Q and ready then
		punchEvent:FireServer()
		ready = false
		wait(0.5)
		ready = true
	end
end

UserInputService.InputBegan:Connect(punch)


5 comments

0

what does the damage script do?

0

I mean, what is the code of the damage script?

0

The damage script is in this script

0

There are a total of 2 scripts here i'm not exactly sure which one is the one that deals the damage

0

The script punches perfectly but does not deal damage