Bomb clone keeps making the actual bomb invisibe

Hello there.

I’m starting to get irritating with this weird bug I’ve encountered when scripting a throwable bomb. I’ve made a module script which includes a function where the bomb explodes after a set time just it for some reason just makes the actual bomb invisible as well.

Module Script

--//Services\\--
local PLRS = game:GetService("Players")
--//Module\\--
local WeaponsModule = {}
--//Sword\\--
--N/A
--//Bomb\\--
function WeaponsModule.TickBomb(Bomb) --Ngl I actually just stole this from the actual bomb gear lol
	
	local updateInterval = .4
	local function Tick()
		updateInterval = updateInterval * .9
	end

	while updateInterval > .1 do
		wait(updateInterval)
		Tick()
		Bomb.Tick:Play()
	end
	--//Explosion\\--
	Bomb["KABOOM!"]:Play()
	local Explosion = Instance.new("Explosion",Bomb)
	Explosion.Position = Bomb.Position
	Explosion.BlastPressure = 1000000
	Explosion.DestroyJointRadiusPercent = 0

	local Hits = {}
	Explosion.Hit:Connect(function(OnHit)
		local Character = OnHit:FindFirstAncestorWhichIsA("Model")
		local Humanoid = Character and Character:FindFirstChildWhichIsA("Humanoid")
		if Humanoid and not Hits[Character] then
			Hits[Character] = true
			Humanoid:TakeDamage(30)
			--//Tagging
			local IsPlayer = PLRS:GetPlayerFromCharacter(Character)
			if IsPlayer then
				local NewTag = Instance.new("ObjectValue",IsPlayer.Character.Humanoid)
				NewTag.Name = "creator"
				NewTag.Value = IsPlayer.Name
				game:GetService("Debris"):AddItem(NewTag,10)
			end
			
			task.wait(2)
			Hits[Character] = false
		end
	end)
	
	Bomb.Transparency = 1
	game:GetService("Debris"):AddItem(Bomb,3)
end

function WeaponsModule.ThrowBomb(Dir, Bomb, ThrowForce)
	local AttachForce = Instance.new("Attachment",Bomb)
	local LinearForce = Instance.new("LinearVelocity",Bomb)
	--Force stuff
	LinearForce.Attachment0 = AttachForce
	LinearForce.MaxForce = math.huge
	LinearForce.VectorVelocity = Dir.LookVector * ThrowForce + Vector3.new(0,30,0)
	game:GetService("Debris"):AddItem(LinearForce,.12)
	
	WeaponsModule.TickBomb(Bomb)
end
return WeaponsModule

Local script

--//Tool\\--
local Tool = script.Parent
--//Character\\--
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
--//Functions\\--
local DB = false
local WeaponsModule = require(game:GetService("ReplicatedStorage").ModuleScripts.WeaponsModule)

Tool.Activated:Connect(function()
	if DB then return end
	DB = true

	local ThrowAnim = Character.Humanoid.Animator:LoadAnimation(Tool.Throw)
	ThrowAnim:Play()
	ThrowAnim:GetMarkerReachedSignal("ThrowBomb"):Connect(function()
		--//Organizing
		local Bomb = Tool.Handle:Clone()
		Bomb.Parent = game.Workspace
		Bomb.CanCollide = true
		Bomb.CFrame = Character.PrimaryPart.CFrame + Character.PrimaryPart.CFrame.LookVector * 3

		WeaponsModule.ThrowBomb(Character.PrimaryPart.CFrame,Bomb,35)
		Tool.Handle.Transparency = 1
	end)

	ThrowAnim.Stopped:Wait()
	Tool.Handle.Transparency = 0
	DB = false
end)

Tool.Equipped:Connect(function()
	local IdleAnim = Character.Humanoid.Animator:LoadAnimation(Tool.Idle)
	IdleAnim:Play()
	Tool.Unequipped:Connect(function()
		IdleAnim:Stop()
	end)
end)

you are doing this after doing the throwBomb function

also, this runs in a local context and therefore will not be able to damage other players

nvm I’m stupid lol. Seems to fixed the issue though, thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.