Hi again. I finished a script and I know there might be a small bug or two, but my main issue is im having trouble knowing where to put it. It is a attack script for a fighting game similar to Project Submas Accudo and the Critical Strike series, after the player walks onto a pad they will get 5 moves. The attack script is a simple on click create a hitbox that does damage, and I just wanna know where to place it. Heres the code:

local player --Depending on where the script is....
local char = player.Character or player.CharacterAdded:Wait()
local mouse = player:GetMouse()
local sword = char:WaitForChild("BSword", math.huge)
local event = game.ReplicatedStorage.ClassData.Bloxxer.BAttack
local part = game.ReplicatedStorage.ClassData.Bloxxer.BloxxerSword:Clone()

local Attackcd = false
local AtCD = .8

local function createhitbox(size1, size2, size3, damage, tim, offset)
 	local hit = game.ReplicatedStorage.HitBox:Clone(workspace)
	hit.Color = Color3.new(100, 0, 0)
	hit.Anchored = true
	hit.CanCollide = false
	hit.Size = Vector3.new(size1, size2, size3)
	hit.CFrame = sword.ToWorldSpace(CFrame.new(0,0,offset))
	local destroy = coroutine.create(function()
		wait(tim)
		if hit then
		hit:Destroy()
		end
	end)
	coroutine.resume()
	
		hit.Touched:Connect(function(h)
			local humanoid = h.Parent.Humanoid or h.Parent:FindFirstChildOfClass("Humanoid")
			print(h)
			humanoid:TakeDamage(damage)
			hit:Destroy()
		end)
	end

mouse.Button1Down:Connect(function()
	print("okok")
	if Attackcd == false and player and player.leaderstats.class.Value == 1 and player.BackPack.Effect.Value == 0 then
		print("okok")

	--the hitbox
	createhitbox(3.1, 2.45, 7.25, 6, .2, 3)
	createhitbox(3.1, 2.45, 7.25, 6, .2, 3)
	createhitbox(3.1, 2.45, 7.25, 6, .2, 3)
	
	Attackcd = true
	
	wait(AtCD)
	
	Attackcd = false
	end
end)

Lemme know what you think!

4 comments

0

if its a local script either starter gui, starter character scripts, starter player scripts, or starterpack. If it's a server script, either server script service or workspace

0

If its a server script, I'd keep it in the server script service

0

But you can't get the player's mouse from the server unless it is passed over by a remote event...

0

Remote events havnt been working for me. They havnt had anything in the output and dont do anything.