hello, so im trying to achieve a rpg in which when you shoot, for example, a part thats in a folder, then it unanchors that part, if you hit the terrain, it will just explode where it got hit., the problem is that i only managed to get the folder destruction to work, and it still doesnt even unanchor
local ReplicatedStorage = game:GetService(‘ReplicatedStorage’)
local remoteEvent = ReplicatedStorage:WaitForChild(‘RPG’)
local hit = ReplicatedStorage.Hit
local DamageToDoIfTheHitIsAPlayer = 0
remoteEvent.OnServerEvent:Connect(function(player, gunPos, gunOr, mosPos)
game:GetService(“ReplicatedStorage”).Launch:Play()
local bullet = Instance.new(“Part”)
bullet.Position = gunPos
bullet.Orientation = gunOr
bullet.Transparency = 0
bullet.Name = ‘Bullet’
bullet.Parent = game.Workspace
bullet.Size = Vector3.new(.25, .25, .25)
bullet.BrickColor = BrickColor.new(‘Neon orange’)
bullet.Shape = Enum.PartType.Block
bullet.CanCollide = true
local speed = 500
bullet.CFrame = CFrame.new(gunPos, mosPos)
bullet.Velocity = bullet.CFrame.lookVector * speed
bullet.Touched:Connect(function(otherPart)
local player = otherPart.Parent.Parent:FindFirstChild("Humanoid")
if not player then
local folder = otherPart.Parent:IsA("Folder")
if folder then
local explosion = Instance.new('Explosion')
explosion.Name = "EXPLOSION"
explosion.Parent = workspace
explosion.BlastRadius = 4
explosion.BlastPressure = 500000
explosion.DestroyJointRadiusPercent = 1
explosion.ExplosionType = Enum.ExplosionType.Craters
explosion.TimeScale = 1
explosion.Position = bullet.Position
explosion.Hit:Connect(function(Hit)
if Hit.Parent:IsA("Folder") then
Hit.Anchored = false
end
end)
end
end
end)
end)