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

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

Asked by 6 years ago

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!

0
wait(0)? theCJarmy7 1293 — 6y
0
It's to make it move smoothly CaptainAlien132 225 — 6y
0
wait(0) does nothing. use 'true' instead AERABER 20 — 6y

1 answer

Log in to vote
1
Answered by
AERABER 20
6 years ago
Edited 6 years ago

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)
0
Didn't work even after editing a few things. CaptainAlien132 225 — 6y
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? CaptainAlien132 225 — 6y
0
Nvm I fixed it. CaptainAlien132 225 — 6y
Ad

Answer this question