I'm just surprised. A few minutes ago, it was working fine (well the bodyvelocity was), and after I fixed some stuff (I forgot game was FE, so I forgot to set up remote events etc. to create parts), the fireball just didn't move.
(My script is 300 lines long, so I just narrowed it down to the part the fireball gets created.)
Here is the part that gets the fireball created:
local shot = game.ReplicatedStorage.CreateFireballShot:InvokeServer(script.Parent.Name, mouse.Hit.p)
And here is the script in ServerScriptService which listens for those remotes:
function game.ReplicatedStorage.CreateFireballShot.OnServerInvoke(plr, name, mpos) local shot = Instance.new("Part", workspace) shot.Name = "Shot/"..plr.Name.."/"..name game.Debris:AddItem(shot, 10) shot.BrickColor = BrickColor.new("Bright orange") shot.Size = Vector3.new(4,4,4) shot.Shape = "Ball" shot.Anchored = false shot.CanCollide = false shot.Transparency = 0.5 shot.BottomSurface = "SmoothNoOutlines" shot.TopSurface = "SmoothNoOutlines" shot.FrontSurface = "SmoothNoOutlines" shot.BackSurface = "SmoothNoOutlines" shot.RightSurface = "SmoothNoOutlines" shot.LeftSurface = "SmoothNoOutlines" shot.CFrame = plr.Character.Torso.CFrame * CFrame.new(0, 0, -4) shot.CFrame = CFrame.new(shot.Position, mpos) local fire = Instance.new("Fire", shot) fire.Size = 15 fire.Heat = 15 local velo = Instance.new("BodyVelocity", shot) velo.maxForce = Vector3.new(math.huge, math.huge, math.huge) velo.velocity = shot.CFrame.lookVector * 80 return shot end
(Also narrowed it down ^)
Woh! This is one of the weirdest scripts I've ever debugged on ScriptingHelpers. I recreated the situation in Studio and, sure enough, the objects don't move even though they are unanchored and have a BodyVelocity
in them.
The first interesting observation is that changing any of the physical properties (rotation, size, shape) of a created fireball in studio in real-time would cause the fireball to zoom off as expected. This suggests that, for some reason, the balls hadn't yet been fully noticed by the physics engine. I'd be intrigued to learn more about why this happens...
In the mean time, I read this article recently, which discusses the relationship between the 2-argument version of Instance.new()
and the physics contact state of a part. Maybe this isn't completely related, but it does solve your problem.
Try setting the parent of shot
after it has been configured. I tested this and it seems to work.