Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a anchored part move?

Asked by 4 years ago
Edited 4 years ago

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...

0
Keep the brick anchored since you won't want the brick to be effected by gravity and add a denounce if needed Nguyenlegiahung 1091 — 4y
0
But the thing is I want it to like get pushed out then fall down so you can acess whats behind it BonkTonkDonk 7 — 4y
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 Nguyenlegiahung 1091 — 4y
0
just tried it, It worked. Thanks! BonkTonkDonk 7 — 4y
View all comments (4 more)
0
;_; did i just lost 15 rep... Nguyenlegiahung 1091 — 4y
0
I'm new to this, what's rep? Is it reputation? BonkTonkDonk 7 — 4y
0
Yep, accept my answer gives me and you reputation :D Nguyenlegiahung 1091 — 4y
0
oh ok BonkTonkDonk 7 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

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

Ad
Log in to vote
1
Answered by
Benbebop 1049 Moderation Voter
4 years ago
Edited 4 years ago

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.

Answer this question