rothan34
(kyara)
January 9, 2023, 6:28pm
#1
I have looked through some codes of some models from the toolbox to learn something, and i saw something similar to “local variable do” and i was confused because i didnt know what this was for.
it seemed to have a function inside of it, which would return something.
is this like making the variable what it returns?
i have tried searching online but to no avail.
please help.
Kaid3n22
(Kaiden)
January 9, 2023, 6:32pm
#2
Could you show the script in which you saw this or at least the essential parts? It would help me explain if I could see it.
I think this is just for organization purposes, nothing special.
local success do
-- This is just a code block
end
-- Also:
do
-- This is valid syntax
end
FunAsiK
(FunAsiK)
January 9, 2023, 6:35pm
#4
I think she means this:
local func do
function func(...)
print(...)
end
end
func("Hello")
rothan34
(kyara)
January 9, 2023, 6:35pm
#5
sorry but i cant, since i have seen it a while back and just thought of it.
While do
is used for loops it has other uses.
I’m assuming you’ve seen that convention in the context of event connections, i.e;
local remoteEvent = workspace.RemoteEvent
local connection do
connection = remoteEvent.OnServerEvent:Connect(function(player)
print(player.Name)
connection:Disconnect()
end)
end
This is essentially a syntactic sugar for the following.
local remoteEvent = workspace.RemoteEvent
local connection
connection = remoteEvent.OnServerEvent:Connect(function(player)
print(player.Name)
connection:Disconnect()
end…
rothan34
(kyara)
January 9, 2023, 6:40pm
#7
yeah i have seen it being used similar to that, never knew why since you could just do this:
function func(...)
print(...)
end
func("Hello")