I am creating a combat system

the script is a local script and the error is .touched doesn’t work

It does not detect anything and no matter how hard I try, nothing works help

local script

local UIS = game:GetService(“UserInputService”)

UIS.InputBegan:Connect(function(input)
print(“test”)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
if ### == nil then
Anim:Play()
game.Players.LocalPlayer.Character.####.Touched:Connect(function(hit)
print(“test2”)
if hit:FindFirstChild(“Humanoid”) or hit.Parent:FindFirstChild(“Humanoid”) then
print(“test3”)
hit.Humanoid.Health -= damage
print(“test4”)
end
end)

probably should try playing the anim from the server, and damage the humanoid from the server as well

because thats why i did with mine

Could you teach me how please?

I don’t know how to do it because I have no idea how to use remote events

Hi, what are you trying to do? Can you explain a bit more what your goal here is.

im trying to do a combat system with combos ( combos like L L L L or L L L R )

create a remote event inside of tool, call it “Event”

local script inside of tool

-- Services
local userInputService = game:GetService("UserInputService")
local players = game:GetService("Players")

-- Folders
local tool = script.Parent
local event = tool.Event

-- Variables
local player = players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
--
local boolean1 = false
local boolean2 = false
local equipped = false
--
local combo = 0

tool.Equipped:Connect(function()
	equipped = true
end)

tool.Unequipped:Connect(function()
	equipped = false
end)

tool.Activated:Connect(function()
	if equipped == true then
		if not boolean1 and not boolean2 then
			boolean1 = true
			combo += 1
			event:FireServer(combo)
			if combo == 4 then
				boolean2 = true
				wait(1.15)
				combo = 0
				boolean2 = false
			end
			wait(0.5)
			boolean1 = false
		end
	end
end)

server script inside of tool

-- Service
local players = game:GetService("Players")

-- Folders
local tool = script.Parent
local event = tool.Event

local Combat = function(action, player, playerCharacter, characterPart)
	if action == "Normal" then
		-- code for doing stuff server sided..
	end
end

event.OnServerEvent:Connect(function(player, combo)
	local character = player.Character
	local humanoid = player.Character:WaitForChild("Humanoid")
	if combo == 1 then
		local action = "Normal"
		Combat(action, player, character, character:WaitForChild("RightHand"))
	end
	if combo == 2 then
		local action = "Normal"
		Combat(action, player, character, character:WaitForChild("LeftHand"))
	end
	if combo == 3 then
		local action = "Normal"
		Combat(action, player, character, character:WaitForChild("RightHand"))
	end
	if combo == 4 then
		local action = "Normal"
		Combat(action, player, character, character:WaitForChild("LeftHand"))
	end
end)

you can utilise this code ive typed, simple enough and that you should do some research. im too tired to currently explain, might go to sleep. bye.

1 Like