Is it possible to call a script, then continue doing the script, even thought the function I want to call has a wait in it?
Thanks.
Is it possible to call a script, then continue doing the script, even thought the function I want to call has a wait in it?
Thanks.
Maybe coroutines. That’s what I use, but I am not sure if that’s the case.
Coroutines for beginners.
In coroutines, you can for example have a loop anf a function run at the same time. So that’s why I think you can use it with wait too.
Another coroutine guide.
You can use them to run multiple tasks at the same time.
Put a RemoteEvent in ReplicatedStorage
localscript
game.ReplicatedStorage.RemoteEvent:FireServer()
script
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function()
print("This script has been called.")
end)
honestly i have no idea if this works.
You can use BindableEvents if both scripts are the same type. Otherwise, use RemoteEvents as @recanman showed.
He wants to run a wait() and a function at the same time, I don’t think another script using bindables is needed.
Its cause I am making a GUI tween borh at the same time.
Oh, Tweens do not yield I think.
Is there anyway for GUIs ro tween at the same time?
Tweens do NOT yield, so just call :Play()
on them right after each other. Therefore, using spawn is unnecessary.
LocalScript:
repeat wait(1) until game:IsLoaded()
local frame = script.Parent --This is a lock image
local White = script.Parent.Parent.White --A white frame
local Black = script.Parent.Parent.Black --a black frame
wait(2)
frame:TweenPosition(UDim2.new(0.444, 0, 0.375, 0)) --Moves lock up
wait(2)
frame:TweenPosition(UDim2.new(0.444, 0, 2.375, 0)) --Moes lock down
Black:TweenPosition(UDim2.new(-2, 0, 0.5, 0)) --moves black frame right
White:TweenPosition(UDim2.new(5.5, 0, 0.5, 0)) --Moves White Frame left
Yes, that will work perfectly.
Bu the problem is:
Black:TweenPosition(UDim2.new(-2, 0, 0.5, 0)) --moves black frame right
White:TweenPosition(UDim2.new(5.5, 0, 0.5, 0)) --Moves White Frame left
--These two play/tween seperatly, i need them both to tween at the same time.
I am currently in studio using :TweenPosition()
and it works simultaneously.
No No No!!!
put the localscript wherever you want and put the script inside the localscript and create a new RemoteEvent
.
Yeah it works but they are both super fast, anyway to make them slower