my script does not seem to work right for some reason why??

This is the script

-- Made By RainbowBeastYT


local tool = script.Parent

local speedboost =1.25

local handle = tool:WaitForChild("Handle")
local event = tool:WaitForChild("RemoteEvent")
local damage = 100
local lastclick = tick()
local swingtime = 1
local combowindow = .5
local combo = 0

local equipped = true
local character = tool.Parent
local player = game.Players:GetPlayerFromCharacter(character)
local humanoid = character:FindFirstChild("Humanoid")
local hithumanoid = {}

	

tool.Equipped:Connect(function()
	lastclick = tick()
	combo = 0
	if humanoid then
		humanoid.Walkspeed = humanoid.Walkspeed * speedboost
	else
		character = nil
	end
end)

tool.Unequipped:Connect(function()
	if humanoid then
		humanoid.Walkspeed = humanoid.Walkspeed / speedboost
	end
	character = nil
	humanoid = nil
end)


handle.Touched:Connect(function(hit)
	if equipped and character and humanoid and humanoid.health > 0 and hit and not hit:isDescendantOf(character) then
		local targethumanoid = hit.Parent:FindFirstChild("Humanoid")
		if targethumanoid and targethumanoid.Health > 0 and not hithumanoid(targethumanoid) then
			hithumanoid[targethumanoid] = true
			targethumanoid:TakeDamage(damage * combo)
		end
	end
end)

tool.Activated:Connect(function()
	local clickdelta = tick() - lastclick
	if clickdelta > swingtime then
	lastclick = tick()
	local hithumanoid = {}
	if clickdelta < swingtime + combowindow then
		combo = (combo + 1) % 3
	else
		combo = 0
	end
	if player then
		if combo == 0 then
			event:FireClient(player, "RunAnimation", "DownStab")
			script.Parent.Handle.Swoosh:Play()
		elseif combo == 1 then
			event:FireClient(player, "RunAnimation", "StabPunch")
			script.Parent.Handle.Swoosh1:Play()
		elseif combo == 2 then
			event:FireClient(player, "RunAnimation", "ThrowCharge")
			script.Parent.Handle.Ting:Play()
			end
		end
	end
end)

This is the local script

-- Made by RainbowBeastYT


local tool = script.Parent
local tuple = (...)



local event = tool:WaitForChild("RemoteEvent")
local character = tool.Parent
local humanoid = character:FindFirstChild("Humanoid")


event.OnClientEvent:Connect(function(mouse)
	local themouse = mouse
	if tuple[2] == "RunAnimation" then
		local anim = tool:FindFirstChild(tuple[2])
		if anim and humanoid then
			local loadedanim = humanoid:LoadAnimation(anim)
			if loadedanim then
				loadedanim:Play()
			end
		end
	end
end)


tool.Equipped:Connect(function(mouse)
	local themouse = mouse
	if humanoid then
		local anim = tool:FindFirstChild("KnifeIdle")
		local loadedidleanim = humanoid:LoadAnimation(anim)
		if anim and humanoid then
			if loadedidleanim then
				loadedidleanim:Stop()
			end
			if loadedidleanim then
				loadedidleanim:Play()
			end
		end
		local anim = tool:FindFirstChild("EquipAnim")
		if anim and humanoid then
			local loadedanim = humanoid:LoadAnimation(anim)
			if loadedanim then
				loadedanim:Play()
			end
		end
	end
end)

tool.Unequipped:Connect(function()
	local anim = tool:FindFirstChild("KnifeIdle")
	local loadedidleanim = humanoid:LoadAnimation(anim)
	if loadedidleanim then
		loadedidleanim:Stop()
	end
end)

please help!

4 comments

0

bro you realize on event you put 2 inputs when firing the events, but you only have space for only 1 of those inputs, and you should be using a remotefunction if your trying to get player.

0

OnClientEvent shouldn't pass client side only objects, like the Mouse. The mouse cannot be obtained from the server, thus being impassable as an argument.

0

Also line 5 of the localscript tuple should be with {} not (). To create a table use curly braces, not brackets.

0

any idea how I can fix it??