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

CFrame line is erroring out when I try to change the position, help?

So I'm trying to change the position so it glides across, like a cannon but the cannon is at a weird angle so I can't make the brick go in a straight line.

I thought of doing a for i loop, but I can't figure out how to set it up

(Sorry if the title is misleading/bad, couldn't think of anything else)

if canfire == true then
	while true do
		local bullet = Instance.new("Part", workspace)
		bullet.CFrame	=	CFrame.new(524.021, 72.038, -120.748)--	*	CFrame.Angles(0, 50, 0) this line might also cause it to error
		bullet.Name = "Bullet"
		bullet.Anchored = false
		bullet.CanCollide = false
		bullet.TopSurface = "Smooth"
		bullet.BottomSurface = "Smooth"
		bullet.Size = Vector3.new(1.5, 1.5, 1.5)
--		bullet.Transparency = 1
		bullet.Position = Vector3.new(524.021, 72.038, -120.748)
		v = Instance.new("BodyVelocity", bullet)
		v.velocity = bullet.CFrame.new(0, 30, 0) -- errors
		v.maxForce = Vector3.new(math.huge, math.huge, math.huge)
		wait(4)
end

(not the full code)

error: 20:34:03.818 - new is not a valid member of CoordinateFrame 20:34:03.820 - Script 'Workspace.Level1.FireballShooter.Script', Line 25 20:34:03.821 - Stack End

(line 25 is line 14 in here)

I know how to use CFrame, but I guess I forgot something.

Thanks

1 answer

✓ Accepted answer

You made it look for a child of CFrame. Instead, you should change line 14 to:

v.velocity = bullet.CFrame = CFrame.new(0, 30, 0)

Also, math.huge is REALLY big. It could crash your game are you sure you want to use it? You can also just say "if canfire then". I reccomend making a local variable rather than global for "v", so I did that too. Finally, you need an end for canfire AND the while true do. So the final script would be:

if canfire then
	while true do
		local bullet = Instance.new("Part", workspace)
	        bullet.CFrame   =   CFrame.new(524.021, 72.038, -120.748)
        	bullet.Name = "Bullet"
	        bullet.Anchored = false
	        bullet.CanCollide = false
	        bullet.TopSurface = "Smooth"
	        bullet.BottomSurface = "Smooth"
	        bullet.Size = Vector3.new(1.5, 1.5, 1.5)
		bullet.Transparency = 1
        	bullet.Position = Vector3.new(524.021, 72.038, -120.748)
        	local v = Instance.new("BodyVelocity", bullet)
        	v.velocity = bullet.CFrame = CFrame.new(0, 30, 0)
        	v.maxForce = Vector3.new(math.huge, math.huge, math.huge)
        	wait(4)
	end
end

4 comments

0

error on line 14 "Expected Identifier, got '='

0

also I already had an end for the while true loop do. Like I said that isn't the full code :P

0

Ah figured it out. I was doing something wrong with another piece of line.

0

lol ok

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