--//Local Script local UIS = game:GetService("UserInputService") local mouse = game.Players.LocalPlayer:GetMouse() local debounce = false

--PC UIS.InputBegan:Connect(function(key, processed) if processed or debounce then return end debounce = true

if key.UserInputType == Enum.UserInputType.Keyboard then
	if key.KeyCode == Enum.KeyCode.Z then
		game.ReplicatedStorage.Events.FireBall:FireServer(mouse.Hit.Position)
	end
end
wait(1)
debounce = false

end)

--Mobile if UIS.TouchEnabled then UIS.TouchTap:Connect(function(position, processed) if processed or debounce then return end debounce = true

	game.ReplicatedStorage.Events.FireBall:FireServer(mouse.Hit.Position)
	wait(1)
	debounce = false
end)

end

--//Server Script game.ReplicatedStorage.Events.FireBall.OnServerEvent:Connect(function(player, mousePos) local effects = game.ReplicatedStorage.FireBallEffects local fireBall = effects.FireBall:Clone() local explosion = effects.Explosion:Clone() local character = player.Character

--Fireball
fireBall.Position = character.HumanoidRootPart.Position
fireBall.Parent = workspace
local velocity = Instance.new("BodyVelocity", fireBall)
velocity.Velocity = CFrame.new(fireBall.Position, mousePos).LookVector * 100

--Explosion
fireBall.Touched:Connect(function(hit)
	if hit:IsDescendantOf(character) or hit:FindFirstChild("ParticleEmitter") then return end
	explosion.Position = fireBall.Position
	fireBall:Destroy()
	explosion.Parent = workspace

	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20)
	end

	wait(1)
	explosion:Destroy()
end)

end)