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

So in a sword, I am confused right off the bat with this script,someone help me understand?

Asked by 5 years ago
local Tool = script.Parent
local GLib = require(206209239)
local GLibScript = GLib.Script
GLibScript.Name = 'GLib'
GLibScript.Parent = Tool
local Sword = require(Tool:WaitForChild'Sword')

if workspace.FilteringEnabled then

    Sword:Initialize()

    Tool:WaitForChild'RemoteClick'.OnServerEvent:connect(function(client, action)
        if client.Character == Tool.Parent then
            Sword:Attack()
        end
    end)
end
Tool.Unequipped:connect(function()
    Sword:Unequip()
end)

Okay so I see "local" being used so much. What does "local" do? Does "local" mean it happens to all players? Next word is "Tool"....shouldn't this say the tool's specific name? What if there are more than one tools in the place? Won't the script break since it just says "tool"??? I have no idea what "require()" means.... God knows what tf GLib is xD. There is nothing on GLib anywhere. This whole thing is really freaking confusing to a beginner. Cna someone break it down near word per word please?

1 answer

Log in to vote
0
Answered by
Pojoto 329 Moderation Voter
5 years ago
Edited 5 years ago

I reaaalllly recommend you go online to learn some of this stuff, because this is the basics, but I'll do my best to explain.

----------------------------------------------------------

When creating variables, you should write "local" first, and then the name of the variable. After that you would make the variable equal to something. A variable can be anything, a number, object, table, effect, true or false... For example:

local thisIsANumber = 5

would make a variable called "thisIsANumber" equal to the number 5. Now in the sword script, you see this: local Tool = script.Parent This means that there is a variable named "Tool" that is equal to the script's parent, wherever the script is located in. If the script was located in a sword, the variable would be equal to the sword. (Don't worry about 'local' for now, just put it before every variable)

Require basically gets access to another script without actually having to own it, and GLib is just a name for something in the script that I don't know about either. I'm not going to explain everything to you though, there's really no point if you don't understand it.

Although it's a good idea to look at free models' scripts and dissect them, you first should learn the basics before tackling harder concepts. I see you are still an early beginner but you also are asking questions on things that you shouldn't be interested in... Take the time to learn the basics, or else you won't understand anything else! I'm only answering your questions to get you started with scripting, but you're going to have to maintain that on your own.

0
okie xD. Thanks! hawkeye1940 8 — 5y
Ad

Answer this question