So these two scripts work together to fire a missile. Don't worry about the missing values. My problem is that more than one missile is fired when I press "w" once, and when they stack on top of each other they explode the cannon.
Local Script:
mouse.KeyDown:connect(function(key)
if key == "w" and currentFighter.Seat:FindFirstChild("SeatWeld") and currentFighter.Seat.SeatWeld.Part1.Parent.Name == plr.Name then
game:GetService("RunService").RenderStepped:connect(function()
local mb = currentFighter.Body.BodyVelocity
mb.Velocity = currentFighter.Body.CFrame.lookVector * 90
end)
end
end)
Server Script:
seat.ChildAdded:connect(function(plr)
fe.OnServerEvent:connect(function(lplr, type)
if type == 1 and seat and seat:FindFirstChild("SeatWeld") and seat.SeatWeld.Part1.Parent:FindFirstChild("Humanoid") then
p = Instance.new("Part")
p.Name = "Missile"
p.Parent = workspace
p.CanCollide = true
local m = Instance.new("SpecialMesh")
m.MeshId = "http://roblox.com/asset/?id=2251534"
m.Parent = p
local spawnPos = body.Position + Vector3.new(0,-11,0)
p.Position = spawnPos
p.Rotation = body.Rotation
p.Velocity = body.CFrame.lookVector * 1000
local col = script.Collision:Clone()
col.Parent = p
col.Disabled = false
wait(.2)
end
end)
end)

2 comments
I can't really say without the missing part of the script, I recommend adding it so the community has a better understanding of how to find a solution towards this problem.
I would simply recommend a debounce.