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 anchored part move?

So, I'm making a game, and I'm trying to make a brick come out of a wall once you touch a red X, and Currently it does not work

local function onTouch(hit)
	print("X has been touched")
	wait(0.1)
	game.Workspace.Brick1.Anchored = false
	wait(0.01)
	game.Workspace.Brick1.Position = Vector3.new(-140.3, 21.704, -129.475)
	wait(0.1)
	game.Workspace.Brick1.Position = Vector3.new(-139.3, 21.704, -129.475)
	wait(0.1)
	game.Workspace.Brick1.Position = Vector3.new(-138.3, 21.704, -129.475)
	wait(0.1)
	game.Workspace.Brick1.Position = Vector3.new(-137.3, 21.704, -129.475)
	wait(0.1)
	game.Workspace.Brick1.Position = Vector3.new(-136.3, 21.704, -129.475)
	wait(0.1)
	game.Workspace.Brick1.Position = Vector3.new(-135.3, 21.704, -129.475)
	wait(0.1)
	

end

script.Parent.Touched:Connect(onTouch)

Any advice? I cant tween yet unfortunately...

8 comments

0

Keep the brick anchored since you won't want the brick to be effected by gravity and add a denounce if needed

0

But the thing is I want it to like get pushed out then fall down so you can acess whats behind it

0

May be unanchored it when it done moving ? The brick will move very weird if you don't anchor it, and add a debounce

0

just tried it, It worked. Thanks!

0

;_; did i just lost 15 rep...

0

I'm new to this, what's rep? Is it reputation?

0

Yep, accept my answer gives me and you reputation :D

0

oh ok

2 answers

✓ Accepted answer

Make sure u unanchored the brick after the movement is done, not before so the brick will move very weird If needed, add a debounce to it

If you cant tween then you should look into how to do it, it is an absolute necessity. It looks intimidating but its not that bad.

    local TweenService = game:GetService("TweenService")
     
    local goal = {}
    goal.Position = Vector3.new(10, 10, 0)
     
    local tweenInfo = TweenInfo.new(5)
     
    local tween = TweenService:Create(part, tweenInfo, goal)
     
    tween:Play()

Goal is what you want the tween to get to, whether this is position, color or even just numbers. TweenInfo is the way it gets there, the interpolation method mostly. Then TweenService:Create is where you compile all that information as well as what you want to do it with.

In your script it would work as follows:

local TweenService = game:GetService("TweenService")
     
    local goal = {}
    goal.Position = Vector3.new(-145.3, 21.704, -129.475)
     
    local tweenInfo = TweenInfo.new(?)
     
    local tween = TweenService:Create(game.Workspace.Brick1, tweenInfo, goal)
     
    tween:Play()

Im not sure what easing style you would want, but I know that 1 = linear which is likely what you want.

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