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

Where should I start if I want to learn how to script Lua on Roblox?

Asked by 4 years ago

I have done scripting for around 6 months. I don't get why I don't get so much better on scripting. Is there a good advice how to be a good scripter and start up?

If there is, Thank you!

Sincerely,

Ducksneedhelp

0
I've been scripting on Roblox for 2 years and I'm still not that good. :/ DesertusX 435 — 4y

3 answers

Log in to vote
3
Answered by 4 years ago
Edited 4 years ago

Hi Ducksneedhelp!

I had a similar issue to you.

For beginner scripters, it's best to start with something simple; like changing BrickColors, printing, etc. Work your way up and read/watch tutorials that actually TEACH you how the script works. if you have a script that is having an error, you can always ask this website. This will also help you understand why you made mistakes.

No script can be too complicated if you learn how they work. Here are some functions that will definitely be useful when scripting:

print(x) 

Print Function: Will print x in the output. This is mainly used for debugging, where the script is erroring.

Example

print("Hello!")

Output: Hello!

for i = x, y, z do
      print(i)
end

x = number it starts at; y = number it will end at; z = number it goes up/down by. Example

for i = 0, 10, 2 do
      print(i)
end

The value of "i" will start at 0, and it will keep going up by 2 until "i" reaches 10.

Output: 0, 2, 4, 6, 8, 10

Instance.new(x, y)

This function, instance.new() makes a new instance, and becomes a child of y.

Example 1

Instance.new("Folder", game.ServerStorage)

This creates a Folder into the ServerStorage.

Example 2

Instance.new("BoolValue", game.ReplicatedStorage)

This creates a BoolValue (Boolean Value aka True or False statement) into ReplicatedStorage.

Here are simple, intermediate, and complicated scripts:

Simple: Change BrickColor

local part = script.Parent --Gets the part

part.BrickColor = BrickColor.new("New Yeller") --Changes the BrickColor of the part to the color "New Yeller"

Intermediate: Changing the Transparency of everything inside the model

local model = script.Parent --Gets the model
for i, v in pairs(model:GetChildren()) do --This `for i` function goes through everything inside the model, as it says `model:GetChildren()`. If you don't know what `:GetChildren()` means, it gets everything inside something. In this case, we get everything inside the model
    if v:IsA("Part") then --If the thing inside the model is a part. We use this to check if the current item inside the model is a part.
        v.Transparency = 1 --The transparency of the part becomes 1
    end
end

Complicated: Datastores

local ds = game:GetService("DataStoreService") --Gets Service of Datastores
local ds1 = ds:GetDataStore("CashDataStore") --Gets the Datastore with the name "CashDataStore"
local ds2 = ds:GetDataStore("WinsDataStore") --Gets the Datastore with the name "WinsDataStore"

game.Players.PlayerAdded:Connect(function(player) --When a player is added
    wait() --Makes sure it loads
    local stats = Instance.new("Folder") --Creates a folder
    stats.Name = "leaderstats" --The name of the folder is "leaderstats"
    stats.Parent = player --The parent of the leaderstats is player
    print("success") --Prints success

    local Cash = Instance.new("IntValue") --Makes a new IntValue, or Integer Value.
    Cash.Name = "Cash" --The name of the IntValue is Cash.
    Cash.Parent = stats --The parent of Cash is stats.
    Cash.Value = ds1:GetAsync(player.UserId) or 0 --If the player has played the game before, they will have a Cash Value already. But if they don't, they will have 0. (Due to the `or 0` part.)
    ds1:SetAsync(player.UserId, Cash.Value) --Sets the datastore of the specific player and the value of cash
    print(Cash.Value) --Prints the cash

    local Wins = Instance.new("IntValue") --Makes another IntValue
    Wins.Name = "Wins" --Name is Wins
    Wins.Parent = stats --parent is stats
    Wins.Value = ds2:GetAsync(player.UserId) or 0 --Again, gets the wins value of the player, or if they haven't played before, has 0.
    ds2:SetAsync(player.UserId, Wins.Value) --Sets value of the specific player and the number of wins.
    print(Wins.Value) --prints wins

    Cash.Changed:Connect(function() --when the value of Cash has changed
        ds1:SetAsync(player.UserId, Cash.Value) --Saves
    end)

    Wins.Changed:Connect(function() --When the value of Wins has changed
        ds2:SetAsync(player.UserId, Wins.Value) --Saves
    end)
end)

You can always go to this website to get more information.

Hope I helped, LennyPlayzYT

0
Thank you for helping me Ducksneedhelp 129 — 4y
0
Looks like it took you some time on those scripts. Well done. You deserve an upvote, Lenny. AntiWorldliness 868 — 4y
0
Thanks! LennyPlayzYT 269 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Lol I say go to the official lua website to start getting ideas of lua which will be very useful if you wanna be a pro I wish you the best ducky brother https://www.lua.org/start.html

0
You also helped Ducksneedhelp 129 — 4y
0
You could have check me :( DuckyRobIox 280 — 4y
Log in to vote
0
Answered by
DesertusX 435 Moderation Voter
4 years ago
Edited 4 years ago

You could go here. It really helped me and I hope it will do the same to you. I recommend reading the article top to bottom. I discovered features in Lua that I have never heard of before!

0
This Really Helped Me As Well! Great Explanation Christopher_magical 9 — 4y
0
No problem! Happy to help! DesertusX 435 — 4y

Answer this question