I've been designing a bubble script for a game that goes in front of your head and increases in size and damage based on a stat, and it increases faster based on a speed stat. However, it seems to hover over the ground instead of next to your head. I assume this is because it resizes faster than it cframes it in front of your player, but honestly I have no idea.
Here's the code:
local tool = script.Parent local name = game.ReplicatedStorage:FindFirstChild("NameVal").Value local player = game.Players:FindFirstChild(name) local char = game.Workspace:WaitForChild(name) local head = char.Head local touchhit = script.TouchHit local bubblegum = Instance.new("Part") touchhit.Parent = bubblegum bubblegum.Transparency = 0.4 bubblegum.CanCollide = false bubblegum.Size = Vector3.new(1, 2, 2) bubblegum.Shape = "Ball" bubblegum.BrickColor = BrickColor.new("Carnation pink") bubblegum.BackSurface = "Smooth" bubblegum.BottomSurface = "Smooth" bubblegum.FrontSurface = "Smooth" bubblegum.LeftSurface = "Smooth" bubblegum.RightSurface = "Smooth" bubblegum.TopSurface = "Smooth" bubblegum.Anchored = true function onUsed() script.Parent.Enabled = false local thing = 1 local size = player.Stats.Size.Value local speed = player.Stats.Speed.Value local clone = bubblegum:clone() clone.Parent = game.Workspace spawn(function (follow) repeat coroutine.yield() clone.CFrame = head.CFrame + head.CFrame.lookVector * thing until done == true end) for i=1, size do clone.Orientation = head.Orientation + Vector3.new(0, 90, 0) clone.Size = clone.Size + Vector3.new(1, 1, 1) thing = thing + 0.5 wait(1 - (speed / 100)) end done = true clone:remove() done = false script.Parent.Enabled = true end function onActivated() if not tool.Enabled then return end tool.Enabled = false onUsed() end script.Parent.Activated:connect(onActivated)
Here's a video of what happens (I increased my size and speed a lot to make it more noticeable): https://www.youtube.com/watch?v=EeT1wBio7co
When you change the size of a part it moves the part if it collides with another part. To fix this you need to reset the CFrame back in front of your head immediately after changing the size.