Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Making a block rise and then stop after a set amount of time?

I'm trying to make a tube from the hunger games but it rises before clicked and doesn't stop after the set time.

local active = false
if workspace.Clickmebutton.ClickDetector.MouseClick
	then
	active = true
end

if active == true then
local brick=script.Parent 
while wait(0) do 
brick.CFrame=brick.CFrame+Vector3.new(0,.133,0) 
wait() 
end 
wait(37.3)
script:Destroy()
end

I'm kind of a noob so please go easy on me!

3 comments

0

wait(0)?

0

It's to make it move smoothly

0

wait(0) does nothing. use 'true' instead

1 answer

✓ Accepted answer

That's not a functional connect event.

Use the TweenService to tween the part to a position rather than attempting to do it through a loop.

Replace x, y and z with the values of the new position.

local tweenService = game:GetService("TweenService")


local clickDetector = workspace:WaitForChild("Clickmebutton").ClickDetector


local seconds = 10


clickDetector.MouseClick:Connect(function()
tweenService:Create(script.Parent, TweenInfo.new(seconds, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {CFrame = CFrame.new(x, y, z}):Play()
end)

3 comments

0

Didn't work even after editing a few things.

0

Alright, I edited it a bit. I gotta thank you for getting me started! But it keeps rotating for some reason, do you know any way to fix that?

0

Nvm I fixed it.

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