Posted
I've seen some codes like:
- FindFirstChild
- Fire...
- Invoke...
What do these codes do?
Where can I use them?
Which one can I use in what kind of script?
Please give some information.
I’m not lazy, I’m just on energy saving mode.
Replied
Cancel
Post
hi123
Replied
@_realnickk thanks for your great explanation. Is it possible to acces a game developer's moderator gui with a script like this.
Cancel
Post
I’m not lazy, I’m just on energy saving mode.
Replied
Simple Explanation:
FindFirstChild: can be used in an if statement, tries to find whatever is called, if not then false
example:
if (workspace:FindFirstChild("RandomPart") then
--random code
end
Fire: used for remoteevents, used to actually turn on the remoteevent.
example:
local revent = workspace.RemoteEvent
revent:FireServer(script.name)
Invoke: i dont actually know what this means so ill let roblox developer studio handle this
Invoke will call the OnInvoke callback and return any values that were returned by the callback (if any). If the OnInvoke callback is not set, this method will yield until one is set. If OnInvoke yields, this method will also yield. There are limitations on the values that can be sent as arguments; see the code samples.
example:
- local bf = script.Parent
- -- Define a function for use with the BindableFunction
- local function AddTwoNumbers(a, b)
- return a + b
- end
- -- Set the OnInvoke callback to be our function
- bf.OnInvoke = AddTwoNumbers
- -- Invoke the BindableFunction
- print(bf:Invoke(25, 44))
Cancel
Post
I am an artist.
Replied
I've seen some codes like:
FindFirstChild
Fire...
Invoke...
What do these codes do? Where can I use them? Which one can I use in what kind of script?
So, let's start off with the first function you listed.
Instance<T>:FindFirstChild(<string> ChildName) is an example of the first one lets say we had a hierarchy such as this one:
https://cdn.discordapp.com/attachments/806571765396144228/807238618619969606/ColorPart_explorer.png
ColorPart is the parent of the child (ColorChangeScript), that may sound like nothing if you're new, but you'll learn how parents of children work in lua.
In this case, we'd do this:
local colorchangescript = workspace:FindFirstChild("ColorPart") -- Will get the script under the part as a child.
Hope this helps, and now we should do Fire in lua! Here's the function desc: BindableEvent<T>:Fire(<string> Scriptname)
Example:
local binding_event = script.Parent
local function event_temp(...) -- Define a simple function to connect to the env
print(...)
end
binding_event.Event:Connect(event_temp)
Too lazy to do invoke, but hope this helps.
Cancel
Post
"Sometimes, giving up is better than trying for hours to achieve nothing."
- Xeon, 2021
To know where you're headed, you must know where you been.
Life is like a pear, except the pear is not real.
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post