Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Part not being positioned by script?

I'm using two beams to simulate the 'trail' of a mortar's shell. One beam goes from the barrel to a dummy part that houses the second beam, and the dummy part attaches itself to the unit it's firing at. The problem is that the dummy part when created positions itself at 0, 0, 0 even though I'm using Part.Position to position it half-way between the mortar and the enemy.

Here is the code in question (I've cut off the rest of the script for readability).

Is the problem that I'm using an equation? Or is it because I should use CFrame?

local maxTrajectory = Instance.new("Part", workspace)
maxTrajectory.Size = Vector3.new(0.05, 0.05, 0.05)
maxTrajectory.Position = Vector3.new((v.Torso.Position + thisUnit.Torso.Position)/2 + Vector3.new(0, 6, 0)) -- i average the positions of the enemy and the unit itself to find the midpoint here and then add 6 to the y-coordinate otherwise the position is level
maxTrajectory.Transparency = 1
maxTrajectory.CanCollide = false
maxTrajectory.Anchored = true
local maxBeam = Instance.new("Beam", maxTrajectory)
maxBeam.CurveSize0 = 2
maxBeam.CurveSize1 = 0
maxBeam.Width0 = 0.05
maxBeam.Width1 = 0.05
maxBeam.Segments = 100
maxBeam.FaceCamera = true

5 comments

0

What about using a trail instead and creating it with Instance.new? https://developer.roblox.com/en-us/api-reference/class/Trail

0

^^ just something to consider!

0

There's no projectile that's being shot, the beam's just eye-candy for raycasting.

0

But looking at the wikipage, this is actually something to consider.

0

Yeah, that's what I thought. I was thinking you could have an invisible part follow the path of the raycast with some sort of tween and have a beam instance.

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.