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 block move up 50 studs, wait 1 second, move down 50 studs, repeat?

So I'm making a parkour game and at some point the block goes up, then down, and up, and down and you have to time it. The problem is I don't know anything about script so I had a friend helping me but his script tends to lag a lot. If you're having WiFi problems the obstacle will teleport and if you're on it, you'll fall through the obstacle. Someone told me try to use "body velocity" and it might help reduce lag. I don't really know how to do any of that. Could anyone help me do it?

5 comments

2

no

0

no

0

lol jk, but could you please post the script your friend made you? It would be helpful to be able to edit something rather than to come up with it from scratch

0

Basically the do

0

CFrames or Vector3s

2 answers

✓ Accepted answer

Ok, so this is my first time helping someone but I recommend using TweenService Im not sure how much this will affect performance but ill give u an example below(in case u wanna use it)


local TweenService = game:GetService("TweenService") 
 
local part = WHATEVER PART
 
local goal = {}
goal.CFrame = Part.CFrame * CFrame.new(0, 50, 0)

local tweenInfo = TweenInfo.new(
	5, -- Time
	Enum.EasingStyle.Quart, -- EasingStyle
	Enum.EasingDirection.Out, -- EasingDirection
	-1, -- RepeatCount (when less than zero the tween will loop indefinitely)
	true, -- Reverses (tween will reverse once reaching it's goal)
	1 -- DelayTime
)
 
local tween = TweenService:Create(part, tweenInfo, goal)
 
tween:Play()

I haven't tested this out so I 110% doubt it would work but its just to give u an idea if you want, u can check out some examples or tutorials on youtube or go read up on TweenService at

https://developer.roblox.com/en-us/api-reference/class/TweenService

so uhh this is my first post on this website so like later today ill edit it if I realise I can make it more appealing or if its breaking any rules

hope this helped

You might want to use CFrame.

local platform = script.Parent --Set this to the part you want to move up and down.

while true do --While loop repeats it
	for i = 0, 100 do
		platform.CFrame = platform.CFrame*CFrame.new(0, .5, 0) --Moves the platform up half a stud 100 times (total 50 studs)
		wait(.001)
	end
	for i = 0, 100 do
		platform.CFrame = platform.CFrame*CFrame.new(0, -.5, 0)	--Moves the platform down half a stud 100 times (total 50 studs)
		wait(.001)
	end
	wait(.1) --Prevents while loop from crashing the game.
end

1 comment

0

you might want to use cframe lerping for that or unless you want to yield the script from executing anything else

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