I want to make my bomb thrown when the weld destroy, but not stay in the same place. How do I make it?
here is my script
local isWearing = false
local UIS = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
game.Players.PlayerAdded:Connect(function(plr)
local bool = Instance.new("BoolValue", plr)
bool.Name = "BombWear"
bool.Value = false
end)
bomb.Touched:Connect(function(hit)
if players:GetPlayerFromCharacter(hit.Parent) then
local plrPlayer = players:GetPlayerFromCharacter(hit.Parent)
if isWearing == false then
isWearing = true
plrPlayer.BombWear.Value = true
local bombExplodeTime = math.random(10, 15 )
local Head = hit.Parent.Head
bomb.CFrame = Head.CFrame * CFrame.new(0, 7, 0)
local Weld = Instance.new("Weld", bomb)
Weld.Part0 = Head
Weld.Part1 = bomb
Weld.C1 = CFrame.new(0,-4,0)
ReplicatedStorage.BombThrow.OnServerEvent:Connect(function()
if plrPlayer.BombWear.Value == true then
if bomb:FindFirstChild("Weld") then
Weld:Destroy()
plrPlayer.BombWear.Value = false
isWearing = false
end
end
end)
for i = 1, bombExplodeTime, 0.1 do
wait(0.1)
bombExplodeTime = bombExplodeTime - 0.1
end
bomb.CanCollide = true
local explosion = Instance.new("Explosion")
explosion.Position = bomb.Position
explosion.BlastRadius = 20
explosion.Parent = game.Workspace
isWearing = false
Weld:Destroy()
bomb.CFrame = bomb.CFrame * CFrame.new(0, 5, 0)
plrPlayer.BombWear.Value = false
isWearing = false
end
end
end)