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