--Complex Combat Punch Script
--Created by SpyGuyTBM
--NOT FOR PUBLIC USE
--Version 0.1.3


local KD = 0
local click = tick()
local Com = 0
local up
local down
local waka
local succ 
local kraken = 0
userInput = game:GetService("UserInputService")


userInput.InputBegan:connect(function(input)
 if input.UserInputType == Enum.UserInputType.Keyboard and input.UserInputState == Enum.UserInputState.Begin and input.KeyCode == Enum.KeyCode.W then
up = true
wait(0.3)
up = false	
end
end)

userInput.InputBegan:connect(function(input)
 if input.UserInputType == Enum.UserInputType.Keyboard and input.UserInputState == Enum.UserInputState.Begin and input.KeyCode == Enum.KeyCode.S then
down = true
wait(0.3)
down = false	
end
end)


userInput.InputBegan:connect(function(input)
 if input.UserInputType == Enum.UserInputType.Keyboard and input.UserInputState == Enum.UserInputState.Begin and input.KeyCode == Enum.KeyCode.G then
 if game.Players.LocalPlayer.leaderstats.MoveActive.Value == 0 then
	
	if tick() - click > 0.5 then
                Com = 0
click = tick()
	        end
	
	if tick() - click < 0.5 then
                Com = Com + 1
click = tick()

	        end
	
	if Com > 3 then
		Com = 1
	end
	
	if up == true then
		Com = 0
	end
	if down == true then
		Com = 0.1
	end
if game.Players.LocalPlayer.leaderstats.MoveActive.Value == 0 then
game.Players.LocalPlayer.leaderstats.MoveActive.Value =1
game.Players.LocalPlayer.leaderstats.Stop.Value = 0
KD=1

succ = 0 -- The Criminal	

if Com == 0 then
	local animTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.TestAnim3)
animTrack:Play()
waka = 0.6	
end

if Com == 0.1 then
	local animTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.ExportAnim)
animTrack:Play()
waka = 0.6	
end

if Com >0 and Com<= 2 and Com~=0.1 then
	local animTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.TestAnim)
animTrack:Play()
waka = 0.2
	
end

if Com == 3 then
	local animTrack = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.TestAnim2)
animTrack:Play()
waka = 0.5	
end
local kraken = 0


game.Players.LocalPlayer.Character["Left Arm"].Touched:connect(function(h)
	
	
	if h.Parent:findFirstChild("Humanoid") and KD == 1  then
		if kraken == 0 then
	local K = game.Players:GetPlayerFromCharacter(h.Parent)
		Damage = 0
		Who = 0
		if K == nil then
			Damage = game.Workspace.Dummy.Damage
		else
			Damage= K.leaderstats.Damage
			if K.leaderstats.Team == game.Players.LocalPlayer.leaderstats.Team then 
				Who = 1
			end
		end
		-- Changes succ to 1
		succ = 1
		if Com == 0.1 then
			if Who == 0 then
			Damage.Value = Damage.Value + 5
			end
				if h.Parent.Torso.CFrame.X - game.Players.LocalPlayer.Character.Torso.CFrame.X >= 0 then
				 Velocity = game.Players.LocalPlayer.Character.Torso.CFrame.lookVector
Velocity = Velocity*(50 + (Damage.Value/1.5))
				h.Parent.Torso.Velocity = Velocity
			end
			if h.Parent.Torso.CFrame.X- game.Players.LocalPlayer.Character.Torso.CFrame.X <= 0 then
				 Velocity = game.Players.LocalPlayer.Character.Torso.CFrame.lookVector
Velocity = Velocity*(50 + (Damage.Value/1.5)) 
				h.Parent.Torso.Velocity = Velocity
			end
 waka = 0.6
		end
		
		if Com == 0 then
			if Who == 0 then
			Damage.Value = Damage.Value + 5
			end
			 Velocity = game.Players.LocalPlayer.Character.Torso.CFrame.lookVector
Velocity =  Vector3.new(0,50 + (Damage.Value/1.5),0)
h.Parent.Torso.Velocity = Velocity 
 waka = 0.6
		end
		


if Com >0 and Com<=2 and Com~=0.1 then
 Velocity = game.Players.LocalPlayer.Character.Torso.CFrame.lookVector
Velocity = (Velocity*8) + Vector3.new(0,10,0)
h.Parent.Torso.Velocity = Velocity 
 waka = 0.2
if Who == 0 then
Damage.Value = Damage.Value + 1
end
end


if Com==3 then
Velocity = game.Players.LocalPlayer.Character.Torso.CFrame.lookVector
Velocity = Velocity *(40 + Damage.Value) + Vector3.new(0,30 + (Damage.Value/2),0)
h.Parent.Torso.Velocity = Velocity 
 waka = 0.5
if Who == 0 then
Damage.Value = Damage.Value + 3
end
end
		end
	end
	kraken = kraken + 1
end)

game.Players.LocalPlayer.Character["Right Leg"].Touched:connect(function(h)
	
	
	if h.Parent:findFirstChild("Humanoid") and KD == 1  then
		if kraken == 0 then
		K = game.Players:GetPlayerFromCharacter(h.Parent)
		Damage = 0
		Who = 0
		if K == nil then
			Damage = game.Workspace.Dummy.Damage
		else
			Damage= K.leaderstats.Damage
			if K.leaderstats.Team == game.Players.LocalPlayer.leaderstats.Team then 
				Who = 1
			end
		end
		-- Changes succ to 1
		succ = 1
		if Com == 0.1 then
			if Who == 0 then
			Damage.Value = Damage.Value + 5
			end
				if h.Parent.Torso.CFrame.X - game.Players.LocalPlayer.Character.Torso.CFrame.X >= 0 then
				local Velocity = game.Players.LocalPlayer.Character.Torso.CFrame.lookVector
Velocity = Velocity*(50 + (Damage.Value/1.5))
				h.Parent.Torso.Velocity = Velocity
			end
			if h.Parent.Torso.CFrame.X- game.Players.LocalPlayer.Character.Torso.CFrame.X <= 0 then
				local Velocity = game.Players.LocalPlayer.Character.Torso.CFrame.lookVector
Velocity = Velocity*(50 + (Damage.Value/1.5)) 
				h.Parent.Torso.Velocity = Velocity
			end
 waka = 0.6
		end
		
		if Com == 0 then
			if Who == 0 then
			Damage.Value = Damage.Value + 5
			end
			local Velocity = game.Players.LocalPlayer.Character.Torso.CFrame.lookVector
Velocity =  Vector3.new(0,50 + (Damage.Value/1.5),0)
h.Parent.Torso.Velocity = Velocity 
 waka = 0.6
		end
		


if Com >0 and Com<=2 and Com~=0.1 then
local Velocity = game.Players.LocalPlayer.Character.Torso.CFrame.lookVector
Velocity = (Velocity*8) + Vector3.new(0,10,0)
h.Parent.Torso.Velocity = Velocity 
 waka = 0.2
Velocity = Vector3.new(0,0,0)
if Who == 0 then
Damage.Value = Damage.Value + 1
end
end


if Com==3 then
local Velocity = game.Players.LocalPlayer.Character.Torso.CFrame.lookVector
Velocity = Velocity *(40 + Damage.Value) + Vector3.new(0,30 + (Damage.Value/2),0)
h.Parent.Torso.Velocity = Velocity 
 waka = 0.5
Velocity = Vector3.new(0,0,0)
if Who == 0 then
Damage.Value = Damage.Value + 3
end
end

		end
	end
	kraken = kraken + 1
end)


wait(waka)
game.Players.LocalPlayer.leaderstats.MoveActive.Value = 0
game.Players.LocalPlayer.leaderstats.Stop.Value = 1
KD = 0
-- Determines what sound to make

if succ == 0 then
	script.Sound2:Play()
end

if succ == 1 then
	script.Sound:Play()
end


	

end
end
end
end)

Now, i dont need you to look thorugh the code, its there if you for some reason want more context (XD no one in their right mind would read it all)

But anyways, this script is a punching script. It is supposed increase the "damage" leaderstat of whoever it hits (even dummies) and give knock back accordingly. It works fine on dummies i have made (they have damage values in them). But there is a problem with punching other players.

The damage leaderstat is only modified on the cleint of whoever punched, and no knockback on any client happens. I assume this happens because the script above is a local script. Any suggestions?

5 comments

0

Is your game filtering enabled.

0

Oh sorry, i meant to mention that. Yes it is

0

Why are we making multiple InptuBegan events just to check for something multiple times? Could just use elseif.

0

The reason for this is because you can do special moves if you click two keys simultaneous ly. The other input begans check for when a key is pressed, and starts a timer. When the main puch button is clicked, if the other button was clicked under a certain amount of time, you do the special move. This has nothing to do with my question though. I request you to help me with my main problem instead

0

of trivial things