So I'm making a C4 and everything works, EXCEPT for the detonation and re-equip, which I'm working on.
Anyway, I'm completely baffled at how this script actually ignores itself. I first used a variable called "Flipped" and it would equal false at the top of the script. That clearly wasn't working, so I tried putting a boolean value inside the script and it reacted the same way!! What do I do? Am I just making a stupid mistake without realizing it?
Here's the function:
--Top of script Flipped = false function Detonate() if not Flipped then --Right here would have the animation, which I'm still working on Tool.Handle.PlantA:Play() print(tostring(Flipped)) Flipped = true print(tostring(Flipped)) elseif Flipped then --Complex explosion... Could be the problem... But it keeps printing "false true, false true" and it's making the sound. But it never says "true false, true false" for i,v in pairs(C4Folder:GetChildren()) do if v.Name == Player.userId.."_C4" then v.Name = Player.userId.."_C4_DETONATE" v.C4Blink.BrickColor = BrickColor.new("Really red") v.C4Blink.Beep:Play() delay(v.C4Blink.Beep.TimeLength, function() local explode = Instance.new("Explosion", workspace) explode.BlastRadius = script.ExplodeRadius.Value explode.Position = v.C4.Position local sound = Instance.new("Sound", v.C4) sound.SoundId = "rbxassetid://142070127" sound.Volume = 1 sound.Pitch = 1 sound:Play() game.Debris:AddItem(v, 3) explode.Hit:connect(function(hit) local Hit_Player = game.Players:GetPlayerFromCharacter(Hit.Parent) or game.Players:GetPlayerFromCharacter(Hit.Parent.Parent) if Hit_Player == nil or not script.AntiTK.Value or (Hit_Player ~= nil and not (not Hit_Player.Neutral and Hit_Player.TeamColor == Player.TeamColor)) then local Humanoid = hit.Parent:FindFirstChild(human) if not Humanoid then --Not there... Humanoid = hit.Parent.Parent:FindFirstChild(human) if not Humanoid then --Didn't hit a gun? Maybe it didn't hit a character at all! return end end if Humanoid == nil or not Humanoid then return end for i,v in pairs(Humanoid:GetChildren()) do if v.Name == "creator" then if v.Value == Player then v:Destroy() end end end local c = Instance.new("ObjectValue") c.Name = "creator" c.Value = Player game.Debris:AddItem(c, 5) c.Parent = Humanoid delay(0, function() if hit then hit.Visible = true wait(script.ReloadTickSpeed.Value) hit.Visible = false end end) end if Hit_Player ~= nil and script.AntiTK.Value then if Hit_Player.TeamColor == Player.TeamColor then explode.BlastPressure = 0 end end end) end) end end print(tostring(Flipped)) Flipped = true print(tostring(Flipped)) end end
I've been constantly looking over this and just can't figure it out! Do I just need to redo this function? Or am I just being completely ignorant and not seeing the simple mistake right in front of me?
well, an observation would be that you have an elseif with flipped = true when you have an if statement making it true