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

How to make a brick appear in a certain place?

I am trying to make a script that spawns a brick in a certain place then make it move. The moving part of it isn't that important unless you have to change the entire script (I don't think you will but, if you have too). Here's the script I have so far:

while true do
	A = Instance.new("Part", workpsace)
	A.Anchored = true
	A.Position = -10, 318.4, -224
	B = Instance.new("SpotLight", A)
	B.Brightness = 5
	B.Range = 20
for loop = 1, 20 do
	A.CFrame = A.CFrame +Vector3.new(0.1, 0, 0)
	wait(0.05)
	end
	wait(5)
	A:remove()
end

The problem being on Line 4 according to the output window. I tried brackets, and that is it. Open to any suggestions.

[Please forgive me for the tags, I didn't know what to class it as so I done the most relevant tags I could think of]

2 answers

✓ Accepted answer

To set the Position of the part, you use Vector3.

while true do
    A = Instance.new("Part", Workspace) -- You spelled Workspace wrong.
    A.Anchored = true
    A.Position = Vector3.new(-10, 318.4, -224) -- Using vector3
    B = Instance.new("SpotLight", A)
    B.Brightness = 5
    B.Range = 20
for loop = 1, 20 do
    A.CFrame = A.CFrame * CFrame.new(0.1, 0, 0) -- You don't add a Vector3 to CFrame, you multiply with another CFrame.
    wait(0.05)
    end
    wait(5)
    A:remove()
end

3 comments

0

You can, and have to, add a vector3 with a cframe. If he wants his part to move at a rate of 0.1 studs every .05 seconds then yes, it'd be adding a Vector3.

0

@Watford, I tested it out right now and it seems that adding a Vector3 will do the same as multiplying a CFrame.

0

Thanks! Testing it now :D

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