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

How to move a part to a small distance?

Asked by 3 years ago
Edited 3 years ago

I need to move the button to a small distance and it looks like it doesn't work. I made a simple script to see what can I do. This is NOT the local script.

local button = script.Parent
wait(10)
button.CFrame = button.ButtonFake.CFrame+Vector3.new(0, 0, 0.027)

ButtonFake is part name. Button is a model.

I don't get any errors and the part is not moving. The part is located in the model. The script is in the part.

I am not very good at scripting and it will be great if you help me. Thanks.

EDIT: I found out that I cannot change the position manually in Play Mode and in the game. Only in studio and Run mode. But why?

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

You Could Try Tween Service:

local TweenService = game:GetService('TweenService')

local TweeningPart = game.Workspace.TweeningPart
local EndingPos = game.Workspace.EndingPosition


local Information = TweenInfo.new(

    10, -- How Long It Will Take To Get The Part Into The Position You Want
    Enum.EasingStyle.Sine, -- EasingStyle
    Enum.EasingDirection.Out, -- Easing Direction
    0, -- How Many Times It Will Repeat
    false, -- Reversed
    0 -- DelayTime
)

local WhatItWillDo = {

    Position = EndingPos.Position

}

local CreateTween = TweenService:Create(TweeningPart, Information, WhatItWillDo)
wait(10) -- // Wait 10 seconds Before Actually Running The Tween {Can Be Changed}
CreateTween:Play()
0
The part needs to be unanchored for the elevator to move (It is an elevator). But for TweenService it needs to be anchored. I tried anchoring the part while the tweenservice is running and then unanchoring again but it returns to its original position. This problem is not a problem in RUN mode tho MegaTestone -5 — 3y
Ad

Answer this question