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

What is the ** syntax in Lua? Please help, since all i've been getting is errors.

Asked by 5 years ago

Hi everyone, I was reading a question on "why my text label is not updating", but when I was reading the code written by the answerer, I came across ** in his code (see below). Please tell me what he means by this.

local Players = game:GetService("Players")

function onPlayerAdded(player)
    local Money = Instance.new("IntValue")
    Money.Name = "Coins"
    Money.Value = 166
    if player.PlayerGui:FindFIrstChild("ScreenGui") then -- this line isn't needed.
      player.PlayerGui.**.ScreenGui.CoinAmount.Text = Money.Value
    end
end


--When a player joins, call the onPlayerAdded function
Players.PlayerAdded:connect(onPlayerAdded) 

--Call onPlayerAdded for each player already in the game
for _,player in pairs(Players:GetPlayers()) do
     onPlayerAdded(player)
end

(This code was written by superhudhayfa)

Thanks, FD284

0
It isn't valid syntax. The asterisk is the multiplication operator for every programming language, and a double asterisk is usually for other purposes, but not in Lua. In C++, a double asterisk is a pointer to a pointer to the value of a variable. In Python, double asterisks are used for exponents. In Lua, they have no use. DeceptiveCaster 3761 — 5y
0
double asterisk also used for tetration in some languages theking48989987 2147 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago

The * symbol is just an arithmetic operator

As for why that is there, I have no idea. Judging from line 7, you can just change line 8 to

player.PlayerGui.ScreenGui.CoinAmount.Text = Money.Value

And speaking of line 7, there is a typo. It's "FindFirstChild" not "FindFIrstChild", just a simple mistake.

0
Ok, thanks flashdrive284 0 — 5y
Ad

Answer this question