This tank fires both its main cannon round and its machine gun during the tests? EVERY single test... but for some odd reason it won't work in the game itself when I put it onto roblox. The game I put it into is Peanut's CTF if you wanna check a visual on how the tank works, but I'm going to describe the situation as best as I can. So sorry about the length but I have no idea on how to fix this or what is needed to fix it.... :I
I think the problem has something to do with the triggering button to fire the guns. These are the scripts for the GUI firing buttons This is the one for the machine gun:
local Firing = false
local Turret = script.Parent.Parent.Turrent
function onClik()
Firing = true
if script.Parent.Reload.Value == true then
script.Parent.Reload.Value = false
repeat
script.Parent.Text = "Firing..."
Turret.Value.Gun.Connector.Fire:play()
local Ray = Ray.new(Turret.Value.Gun.Connector.Position, (Turret.Value.Gun.Connector.CFrame.lookVector).unit*999)
local Hit,Position = game.Workspace:FindPartOnRay(Ray,Turret.Value)
if Hit then
if Hit.Parent:FindFirstChild("Humanoid") then
Hit.Parent.Humanoid:TakeDamage(15)
end
end
local RayPart = Instance.new("Part",Workspace)
RayPart.Name = "RayPart"
RayPart.BrickColor = BrickColor.new("New Yeller")
RayPart.Anchored = true
RayPart.CanCollide = false
RayPart.TopSurface = Enum.SurfaceType.Smooth
RayPart.BottomSurface = Enum.SurfaceType.Smooth
RayPart.formFactor = Enum.FormFactor.Custom
local Distance = (Position-Turret.Value.Gun.Connector.CFrame.p).magnitude
RayPart.Size = Vector3.new(0.2,0.2,Distance)
RayPart.CFrame = CFrame.new(Position,Turret.Value.Gun.Connector.CFrame.p) * CFrame.new(0,0,-Distance/2)
game.Debris:AddItem(RayPart,0.05)
wait(.1)
until Firing == false
end
script.Parent.Text = "..."
wait(1)
script.Parent.Reload.Value = true
script.Parent.Text = "FIRE"
end
function unClik()
if Firing == true then
Firing = false
end
end
script.Parent.MouseButton1Down:connect(onClik)
script.Parent.MouseButton1Up:connect(unClik)
This is the one for the cannon.
function onClik()
if script.Parent.Reload.Value == true then
script.Parent.Reload.Value = false
script.Parent.Parent.Turrent.Value.Connector2.Fire:play()
missile = Instance.new("Part")
missile.Parent = game.Workspace
missile.formFactor = 0
missile.Size = Vector3.new(1, 1, 4)
missile.TopSurface = 0
missile.BottomSurface = 0
missile.CanCollide = false
missile.Name = "Missile"
sound = Instance.new("Sound")
sound.Parent = missile
sound.SoundId = "abc837c5f2d48f958d5e450fbc98fe91"
sound.Pitch = 2
sound.Name = "Hit"
missile.BrickColor = BrickColor.new(199)
missile.CFrame = script.Parent.Parent.Turrent.Value.Connector2.CFrame * CFrame.new(0, 1.5, -20)
missile.Velocity = script.Parent.Parent.Turrent.Value.Connector2.CFrame.lookVector * 600
script.Parent.Parent.Turrent.Value.Parent.Engine.Velocity = script.Parent.Parent.Turrent.Value.Connector2.CFrame.lookVector * 150
scr = script.Clean:clone()
scr.Disabled = false
scr.Parent = missile
script.Explode:clone().Parent = missile
mesh = Instance.new("SpecialMesh")
mesh.Parent = missile
mesh.MeshType = 3
mesh.Scale = Vector3.new(0.3, 0.3, 0.7)
script.Parent.Text = "-"
objnum2 = Instance.new("ObjectValue")
objnum2.Name = "Owner"
objnum2.Value = script.Parent.Parent.Parent.Parent.PlayerGui
objnum2.Parent = missile
script.Parent.Parent.Turrent.Value.Blast.Transparency = 0
wait(0.1)
script.Parent.Parent.Turrent.Value.Blast.Transparency = 1
for i = 1, 10 do
script.Parent.Text = script.Parent.Text.."-"
wait(0.1)
end
script.Parent.Reload.Value = true
script.Parent.Text = "FIRE"
end
end
script.Parent.MouseButton1Click:connect(onClik)
