Explode as in different spheres expanding outwards on contact with a surface. Not exploding like a grenade.

Player = game.Players.LocalPlayer
local Mouse = game.Players.LocalPlayer:GetMouse()
Ammo = 1

Mouse.KeyDown:Connect(function(key)
	key = key:lower()
	if key == "f" and Ammo>0 then
		local x = Instance.new("Part", workspace)
		x.Shape = "Ball"
		x.BrickColor = BrickColor.new("Deep orange")
		x.Transparency = 0.3
		x.TopSurface = "Smooth"
		x.BottomSurface = "Smooth"
		x.CanCollide = false
		x.Parent = workspace
		x.CFrame = Player.Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-6)
		local v = Instance.new("BodyVelocity",x)
		v.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
		v.Velocity = (x.Position - Mouse.hit.p).unit*-100
		
		Ammo = Ammo-1
		wait(2)
		Ammo = 1
		x:remove()
		
	end
end)

5 comments

0

Use a touched function on the Part called X

0

Listen to Touched of x. When fired, increase the size of x and disconnect the event using Disconnect. Fyi, (x.Position - mouse.Hit.Position).Unit is the same thing mouse.Hit.LookVector

0

Actually i suggest creating a new part and setting its position to x for the explosion instead of increasing the size of the original projectile

0

^

0

I got it fixed. using a script instead of a Local Script.