So i made a railgun. It has a battery, coolant, reloading and broken system ( Meaning its very realistic ) All the features work fine, except for the firing system. I have values in workspace to tell if everything is on. heres my code:
local closeAnim = require(game.Workspace.door.Animator)
local debounce = false
local g1 = game.Workspace.gen1.Value
local g2 = game.Workspace.gen2.Value
local g3 = game.Workspace.gen3.Value
local reloaded = game.Workspace.reloaded.Value
local broken = game.Workspace.broken.Value
local coolant = game.Workspace.coolantValue.Value
local rocket = game.ServerStorage.Rocket
function onClicked(playerWhoClicked)
script.Parent.Transparency=1
if g1 and g2 and g3 and reloaded and coolant then
print("ready to fire")
if broken == false then
local clone = rocket:Clone()
local brokenChance = math.random(0,4)
clone.Parent = game.Workspace
game.ReplicatedStorage.CameraShake:FireAllClients()
game.Workspace["Wind Whoosh Sonic Boom Low End Impact 2 (SFX)"]:Play()
game.Workspace["Big Explosion"]:Play()
closeAnim.NewTween1:Play()
reloaded = false
if brokenChance == 2 then
broken = true
game.ServerStorage.Fire.Parent = game.Workspace
game.Workspace.brokenPart.ProximityPrompt.Enabled = true
end
else
script.Parent.ProximityPrompt.ActionText = "Component not on or broken"
wait(2)
script.Parent.ProximityPrompt.ActionText = "Fire"
end
end
wait(.1)
script.Parent.Transparency=0
end
script.Parent.ProximityPrompt.Triggered:Connect(onClicked)
its not even printing the “ready to fire”
my theory is that somethings wrong with the first if statement. i dont know how to use ands so i just decided to wing it( i dont even know if ands are a thing ). perhaps thats the problem?