I want to make this to where the people around can get hit instead of the people you are looking at. The Local Script is placed in starterpack. In the local script is a remote event and in the remote event is the server script. In the server script are the animations and sound

---Server Script
local Cooldown = false
local Combo = 0
local Delay = .35
local BasicAttack = 5 
local FinalCombo = 10
local TimeToAttack = .8 
local WSDBF = 0
local Delayersp = .1 

script.Parent.OnServerEvent:Connect(function(Player, Stunned)
if Stunned.Value == true then return end 	
Combo = Combo + 1 

local SwingFist = Instance.new("Sound")
SwingFist.SoundId = "http://www.roblox.com/asset/?id=28166555"
SwingFist.MaxDistance = 100 
SwingFist.Parent = Player.Character.HumanoidRootPart
game.Debris:AddItem(SwingFist,.5)

if Combo == 1 then  

local rightPunch = Player.Character.Humanoid:LoadAnimation(script.rightPunch)
rightPunch:Play() 
SwingFist:Play()

local ray = Ray.new(Player.Character.HumanoidRootPart.Position, Player.Character.HumanoidRootPart.CFrame.lookVector * 8)
local hit = workspace:FindPartOnRay(ray, Player.Character)

if hit and hit.Parent:FindFirstChild("Humanoid") then 
 
	hit.Parent.Humanoid:TakeDamage(BasicAttack)
	
	local Punched1 = script.Punched1:Clone()
	Punched1.Parent = hit.Parent.HumanoidRootPart
	Punched1:Play()
	game.Debris:AddItem(Punched1,.5)
	local track = hit.Parent.Humanoid:LoadAnimation(script.PunchedLeft)
	track:Play()
	local BodyVelocity = Instance.new("BodyVelocity",Player.Character.HumanoidRootPart)
	BodyVelocity.Velocity = Player.Character.HumanoidRootPart.CFrame.lookVector * 10
	BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	game.Debris:AddItem(BodyVelocity,.1)
	local NormalHit = game.ReplicatedStorage.NormalHit:Clone()
	NormalHit.Parent = workspace
	local Weld = Instance.new("Weld",NormalHit)
	Weld.Part0 = NormalHit
	Weld.Part1 = hit.Parent.Head
	Weld.C1 = CFrame.new(0,0,-1)
	game.Debris:AddItem(NormalHit,.3)
	hit.Parent.Humanoid.WalkSpeed = hit.Parent.Humanoid.WalkSpeed - WSDBF
	
	spawn(function()
		wait(Delay+Delayersp)
		hit.Parent.Humaoid.WalkSpeed = hit.Parent.HumanoidWalkSpeed + WSDBF
	end)
	
end





spawn(function()
	wait(TimeToAttack)
	if Combo == 2 then 
	else  
		Combo = 0 
	end
end)


else if Combo == 2 then 

spawn(function()
	wait(TimeToAttack)
	if Combo == 3 then 
	else  
		Combo = 0 
	end
end)

local leftPunch = Player.Character.Humanoid:LoadAnimation(script.leftPunch)
leftPunch:Play() 
SwingFist:Play()

local ray = Ray.new(Player.Character.HumanoidRootPart.Position, Player.Character.HumanoidRootPart.CFrame.lookVector * 8)
local hit = workspace:FindPartOnRay(ray, Player.Character)

if hit and hit.Parent:FindFirstChild("Humanoid") then 
	hit.Parent.Humanoid:TakeDamage(BasicAttack)
	
	local Punched2 = script.Punched2:Clone()
	Punched2.Parent = hit.Parent.HumanoidRootPart
	Punched2:Play()
	game.Debris:AddItem(Punched2,.5)
	local track = hit.Parent.Humanoid:LoadAnimation(script.PunchedRight)
	track:Play()
	local BodyVelocity = Instance.new("BodyVelocity",Player.Character.HumanoidRootPart)
	BodyVelocity.Velocity = Player.Character.HumanoidRootPart.CFrame.lookVector * 10
	BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	game.Debris:AddItem(BodyVelocity,.1)
		local NormalHit = game.ReplicatedStorage.NormalHit:Clone()
	NormalHit.Parent = workspace
	local Weld = Instance.new("Weld",NormalHit)
	Weld.Part0 = NormalHit
	Weld.Part1 = hit.Parent.Head
	Weld.C1 = CFrame.new(0,0,-1)
	game.Debris:AddItem(NormalHit,.3)
	
		hit.Parent.Humanoid.WalkSpeed = hit.Parent.Humanoid.WalkSpeed - WSDBF
	
	spawn(function()
		wait(Delay+Delayersp)
		hit.Parent.Humaoid.WalkSpeed = hit.Parent.HumanoidWalkSpeed + WSDBF
	end)
	
end


else if Combo == 3 then 

local rightUpperCut = Player.Character.Humanoid:LoadAnimation(script.rightUpperCut)
rightUpperCut:Play()
SwingFist:Play()

spawn(function()
	wait(TimeToAttack)
	if Combo == 4 then 
	else  
		Combo = 0 
	end
	local RightArm = false
end)

local ray = Ray.new(Player.Character.HumanoidRootPart.Position, Player.Character.HumanoidRootPart.CFrame.lookVector * 8)
local hit = workspace:FindPartOnRay(ray, Player.Character)

if hit and hit.Parent:FindFirstChild("Humanoid") then 

	hit.Parent.Humanoid:TakeDamage(BasicAttack)
	
	local Punched3 = script.Punched3:Clone()
	Punched3.Parent = hit.Parent.HumanoidRootPart
	Punched3:Play()
	game.Debris:AddItem(Punched3,.5)
	local track = hit.Parent.Humanoid:LoadAnimation(script.leftUpperCutPunch)
	track:Play()
	local BodyVelocity = Instance.new("BodyVelocity",Player.Character.HumanoidRootPart)
	BodyVelocity.Velocity = Player.Character.HumanoidRootPart.CFrame.lookVector * 10
	BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	game.Debris:AddItem(BodyVelocity,.1)
		local NormalHit = game.ReplicatedStorage.NormalHit:Clone()
	NormalHit.Parent = workspace
	local Weld = Instance.new("Weld",NormalHit)
	Weld.Part0 = NormalHit
	Weld.Part1 = hit.Parent.Head
	Weld.C1 = CFrame.new(0,0,-1)
	game.Debris:AddItem(NormalHit,.3)
	
		hit.Parent.Humanoid.WalkSpeed = hit.Parent.Humanoid.WalkSpeed - WSDBF
	
	spawn(function()
		wait(Delay+Delayersp)
		hit.Parent.Humaoid.WalkSpeed = hit.Parent.HumanoidWalkSpeed + WSDBF
	end)
	
end


else if Combo == 4 then 

local leftUpperCut = Player.Character.Humanoid:LoadAnimation(script.leftUpperCut)
leftUpperCut:Play()
SwingFist:Play()

spawn(function()
	wait(TimeToAttack)
	if Combo == 5 then 
	else  
		Combo = 0 
	end
	local RightArm = false
end)


local ray = Ray.new(Player.Character.HumanoidRootPart.Position, Player.Character.HumanoidRootPart.CFrame.lookVector * 8)
local hit = workspace:FindPartOnRay(ray, Player.Character)

if hit and hit.Parent:FindFirstChild("Humanoid") then 

	hit.Parent.Humanoid:TakeDamage(BasicAttack)

	local Punched4 = script.Punched4:Clone()
	Punched4.Parent = hit.Parent.HumanoidRootPart
	Punched4:Play()
	game.Debris:AddItem(Punched4,.5)
	local track = hit.Parent.Humanoid:LoadAnimation(script.rightUpperCutFace)
	track:Play()
		local Punched4 = script.Punched4:Clone()
	Punched4.Parent = hit.Parent.HumanoidRootPart
	Punched4:Play()
	local BodyVelocity = Instance.new("BodyVelocity",Player.Character.HumanoidRootPart)
BodyVelocity.Velocity = Player.Character.HumanoidRootPart.CFrame.lookVector * 10
BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
game.Debris:AddItem(BodyVelocity,.1)
	local NormalHit = game.ReplicatedStorage.NormalHit:Clone()
	NormalHit.Parent = workspace
	local Weld = Instance.new("Weld",NormalHit)
	Weld.Part0 = NormalHit
	Weld.Part1 = hit.Parent.Head
	Weld.C1 = CFrame.new(0,0,-1)
	game.Debris:AddItem(NormalHit,.3)
	
		hit.Parent.Humanoid.WalkSpeed = hit.Parent.Humanoid.WalkSpeed - WSDBF
	
	spawn(function()
		wait(Delay+Delayersp)
		hit.Parent.Humaoid.WalkSpeed = hit.Parent.HumanoidWalkSpeed + WSDBF
	end)
	
end

else if Combo == 5 then

local Kick = Player.Character.Humanoid:LoadAnimation(script.Kick)
Kick:Play()
SwingFist:Play()

local ray = Ray.new(Player.Character.HumanoidRootPart.Position, Player.Character.HumanoidRootPart.CFrame.lookVector * 8)
local hit = workspace:FindPartOnRay(ray, Player.Character)

if hit and hit.Parent:FindFirstChild("Humanoid") then 

	hit.Parent.Humanoid:TakeDamage(FinalCombo)

	local track = hit.Parent.Humanoid:LoadAnimation(script.kickFace)
	track:Play()
			local Punched5 = script.Final:Clone()
	Punched5.Parent = hit.Parent.HumanoidRootPart
	Punched5:Play()
	local BodyVelocity = Instance.new("BodyVelocity",hit.Parent.HumanoidRootPart)
		BodyVelocity.Velocity = hit.Parent.HumanoidRootPart.CFrame.lookVector * -50
		BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
		game.Debris:AddItem(BodyVelocity,.6)
		local BodyVelocity = Instance.new("BodyVelocity",Player.Character.HumanoidRootPart)
BodyVelocity.Velocity = Player.Character.HumanoidRootPart.CFrame.lookVector * 10
BodyVelocity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
game.Debris:AddItem(BodyVelocity,.1)
local NormalHit = game.ReplicatedStorage.NormalHit:Clone()
	NormalHit.Parent = workspace
	local Weld = Instance.new("Weld",NormalHit)
	Weld.Part0 = NormalHit
	Weld.Part1 = hit.Parent.Head
	Weld.C1 = CFrame.new(0,0,-1)
	game.Debris:AddItem(NormalHit,.3)

	hit.Parent.Humanoid.WalkSpeed = hit.Parent.Humanoid.WalkSpeed - WSDBF
	
	spawn(function()
		wait(Delay+Delayersp)
		hit.Parent.Humaoid.WalkSpeed = hit.Parent.HumanoidWalkSpeed + WSDBF
	end)
	
end


Combo = 0	




				end
			end			
		end	
	end
end
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
end)

--Local Script

wait(2)

local Cooldown = false
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Stunned = Character.Stunned
local Mouse = Player:GetMouse()
local Delay = .35

Mouse.Button1Down:Connect(function()
if Stunned.Value == true then return end 
if Cooldown then return end 
for _, v in pairs(Player.Character:GetChildren()) do
if v:IsA("Tool") then return end
end	

spawn(function()
	Cooldown = true
	wait(Delay)
	Cooldown = false 
end)

script.RemoteEvent:FireServer(Stunned)	
	

local ray = Ray.new(Player.Character.HumanoidRootPart.Position, Player.Character.HumanoidRootPart.CFrame.lookVector * 8)
local hit = workspace:FindPartOnRay(ray, Player.Character)

hit.Parent.Stunned.Value = true

spawn(function()
	wait(Delay+6)
	hit.Parent.Stunned.Value = false 
end)
	
	
end)

3 comments

0

Is this a tool or a keydown function?

0

Keydown function

0

I have some basic knowledge of Magnitude and would like to help, but I'm not clear on exactly what the question is and tbh im not too keen on trying to figure it out from 300+ lines of code. Could you clarify please?