[Coding Help] how would I code a line inside my script for it to wait for a tween to end?
Posted
rn ive got this script which is like a grab all chests (still doesnt work that good) but I made the teleporting phase into a tween, and instead of using wait() which is kinda janky I want my script to directly pause until the tween is fully finished, how would I go by doing this?
current code:
game:GetService("TweenService"):Create(game:GetService("Players").LocalPlayer.Character.HumanoidRootPart, TweenInfo.new(5, Enum.EasingStyle.Linear), { CFrame = chest.CFrame * CFrame.new(3,0,0)}):Play()
task.wait(5)Replied
Do you want to know when the tween ends?
local Tween = game:GetService('TweenService'):Create....
Tween.Completed:Connect(function()
--Stuff
end)
Roblox Docs: TweenBase#Completed
Cancel
Post
I'm not lazy, I'm just highly motivated to do nothing. #I💚Dogs.
Replied
havent tested yet, but theres a 99% chance that this works, ty all! thread locked
Cancel
Post
Added
nvm unlocking this, now I get an error "attempt to index nil with Completed" ik what that means but in the code im defining the tween so it doesnt make sense
local tween = game:GetService("TweenService"):Create(game:GetService("Players").LocalPlayer.Character.HumanoidRootPart, TweenInfo.new(5, Enum.EasingStyle.Linear), { CFrame = chest.CFrame * CFrame.new(3,0,0)}):Play()
tween.Completed:Wait()Cancel
Post
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post