Crates may spawn and parachute from the sky in my game. You are able to get a cannon and a few other things from these crates. In the case that a player has already gotten a crate, it should give you more cannon ammo instead of another cannon.
Basically, for some reason if elseif not Tool then
succeeds, then it will continue with the rest of the script, though if Tool then
succeeds it will not finish the rest of the script like it should.
local ProximityPrompt = script.Parent.ProximityPrompt
local Flare = script.Parent.Parent.Flare
ProximityPrompt.Triggered:Connect(function(Player)
ProximityPrompt.Enabled = false
local Tool = Player.Backpack:FindFirstChild("Cannon") or Player.Character:FindFirstChild("Cannon")
if Tool then
local AdditionalAmmoTool = Player.Backpack:FindFirstChild("Cannon") or Player.Character:FindFirstChild("Cannon")
AdditionalAmmoTool.Ammo.Value = AdditionalAmmoTool.Ammo.Value + 7
elseif not Tool then
local ToolsCopy2 = game.ReplicatedStorage.Cannon:Clone()
ToolsCopy2.Parent = Player.Backpack
local ToolsCopy = game.ReplicatedStorage["Health Potion"]:Clone()
ToolsCopy.Parent = Player.Backpack
local ToolsCopy3 = game.ReplicatedStorage.Trumpet:Clone()
ToolsCopy3.Parent = Player.Backpack
script.Parent.Parent.Box.Open:Play()
Flare.ParticleEmitter.Enabled = false
Flare.PointLight.Enabled = false
Flare.Smoke.Enabled = false
script.Parent.Parent.Box.FlareSound.Playing = false
script.Parent.Parent.Cap.WeldToRest:Destroy()
script.Parent.Parent.Cap.LinearVelocity.Enabled = true
wait(0.3)
script.Parent.Parent.Cap.LinearVelocity.Enabled = false
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, 53839582) then
local NewTool = Player.Backpack:FindFirstChild("Cannon") or Player.Character:FindFirstChild("Cannon")
NewTool.Ammo.Value = NewTool.Ammo.Value + 7
wait(20)
script.Parent.Parent.Parent:Destroy()
end
end
end)
Any help would be much appreciated!