This script so far shoots a part by the "UpperTorso" CFrame, but I want it so the part to shoot at the x or y or z position of the mouse and how could I debounce this, so it doesn't keep shooting forever.
Here is the current script:
local p = script.Parent
p:WaitForChild("Handle")
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local speed = script.Parent.Speed.Value
local x = math.random(-10,10)
local y = script.Parent.Top.Position.Y - 70
local z = math.random(-10,20)
p.Activated:Connect(function()
local Debounce = false
local part = game.ReplicatedStorage.Part
local partClone = part:Clone()
partClone.Parent = game.Workspace
if player.Character then
local offset = Vector3.new(0,0,-10)
partClone.CFrame = player.Character.UpperTorso.CFrame * CFrame.new(offset)
partClone.Velocity = player.Character.UpperTorso.CFrame.lookVector * speed + Vector3.new(x,y,z)
partClone.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and Debounce == false and hit.Parent.Name ~= script.Parent.Holder.Value then
hit.Parent.Humanoid:TakeDamage(10)
wait(0.1)
Debounce = false
partClone:Destroy()
else
wait(1)
partClone:Destroy()
end
end)
wait(1)
partClone:Destroy()
end
end)
Thanks for the Help!
