FiveM 'then' expected near '=' - lua

Hello when i start the server and want to start doing illegal jobs this shows up
brx-drugs/client/client.lua:50: 'then' expected near '='
and here is also a piece of the code
Citizen.CreateThread(function()
while true do
Citizen.Wait(1000)
local pedCoords = GetEntityCoords(GetPlayerPed(-1))
local dst = #(Config.StartLocation - pedCoords)
if dst < 200 and jobSpawned = false then
TriggerEvent ('brx-drugs:spawnJobPed',Config.StartLocation, 217.980
jobSpawned = true
refreshJobPed = true
end
if dst>= 201 then
if DoesEntityExist(jobPed) then
DeletePed(jobPed)
end
JobSpawned = false
end
end
end)
i dont think the problem is with the config file and i cant get around it since im a new dev

Missing '=' in
if dst < 200 and jobSpawned = false then
jobSpawned = false
Change to
jobSpawned == false

Related

how do i fix ')' (to close '(' at line 38), got '.'

for i, v in pairs(Buttons:GetChildren()) do
local NewItem = BoughtItems:FindFirstChild(v.Item.value)
if NewItem ~= nil then
Items[NewItem.Name] = NewItem:Clone()
NewItem:Destroy()
else
v.ButtonPart.Transparency = 1
v.ButtonPart.CanCollide = false
v.ButtonPart.BillBoardGui.Frame.Visible = false
end
if v:FindFirstChild("Dependency") then
coroutine.resume(coroutine.create(function(
v.ButtonPart.Transparency = 1
v.ButtonPart.CanCollide = false
v.ButtonPart.BillBoardGui.Frame.Visible = false
if BoughtItems:WaitForChild(v.Dependency.Value, 100000)then
v.ButtonPart.Transparency = 0
v.ButtonPart.CanCollide = true
v.ButtonPart.BillBoardGui.Frame.Visible = true
end
end))
end
v.ButtonPart.Touched:Connect(function(Hit)
if Hit.Parent:FindFirstChild("Humanoid")then
local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
if Values.OwnerValue.Value == Player then
if v.ButtonPart.CanCollide == true and v.ButtonPart.Transparency == 0 then
if Player:WaitForChild("leaderstats").Cash.Value >= v.Price.Value then
Player.leaderstats.Cash.Value -= v.Price.Value
Items[v.Item.Value].Parent = BoughtItems
v:Destroy()
end
end
end
end
end)
end
how do i fix this the header is the problem i dont knw what it means so is there a fix to it for my tycoon if anyone knows pls comment (heres some random stuff since my post is mostly code) A brief Introduction to Copypasta. Copypasta means to copy a text or a part of the text from an existing manuscript and inclusion of that very text in an under-process manuscript by pasting. At present, the societies are going to be expanded with an enormous pattern.
Parenthesis always come in pairs. The error message already strongly suggests that you are missing a closing parenthesis for an opening one in line 38.
1 2 3
coroutine.resume(coroutine.create(function(
v.ButtonPart.Transparency = 1
v.ButtonPart.CanCollide = false
v.ButtonPart.BillBoardGui.Frame.Visible = false
if BoughtItems:WaitForChild(v.Dependency.Value, 100000)then
v.ButtonPart.Transparency = 0
v.ButtonPart.CanCollide = true
v.ButtonPart.BillBoardGui.Frame.Visible = true
end
end)) <--- one is missing
1 2
Use a text editor that autocompletes pairs or even better one that hightlights pairs in matching colors to avoid errors like this.

attempt to compare nil < number?

Im trying to change to get the zamount's value in the client side but it returns it as nil, can anyone help??
script:
script.Parent.MouseClick:Connect(function(plr)
if plr.Team == game.Teams.Mastermind then
local zombiespawn = script.Parent.Parent
game.ReplicatedStorage.Events:WaitForChild("Onzombiespawnclick"):FireAllClients(plr,script.Parent.Parent.CFrame ,zombiespawn)
end
end)
Local script:
game.ReplicatedStorage.Events:WaitForChild("Onzombiespawnclick").OnClientEvent:Connect(function(spawncframe, zombiespawn)
script.Parent.Visible = true
zombiespawnreference = spawncframe
zombieamountreference = zombiespawn:FindFirstChild("Zombieamount").Value
end)
if zombieamountreference < game.ReplicatedStorage.Vals:WaitForChild("Zombieamountlimit").Value then
if not debounce then
debounce = true
script.Parent:WaitForChild("Placeevent"):FireServer(zombiename, zombiespawnreference, power, zombieamountreference)
wait(0.3)
debounce = false
end
end
Nevermind, i had to put a player object on the client event parameter thing. Its fixed now

LUA unexpected symbol near ')'

fivem
local loaded = false
function loadTxd(source, args, raw)
local txd = CreateRuntimeTxd('duiTxd')
local duiObj = CreateDui('https://media.discordapp.net/attachments/813996951066116097/854844624114548786/lcd_sign1.gif', 4096, 1024)
_G.duiObj = duiObj
local dui = GetDuiHandle(duiObj)
local tx = CreateRuntimeTextureFromDuiHandle(txd, 'duiTex', dui)
AddReplaceTexture('bus', 'lcd_sign_1', 'duiTxd', 'duiTex')
end)
Citizen.CreateThread function loadTxd(source, args, raw)
while loaded == false do
Wait(0)
local playerCar = GetVehiclePedIsIn(GetPlayerPed(-1))
if playerCar ~= 0 then
if GetEntityModel(playerCar) == GetHashKey('bus') then
loadTxd()
loaded = true
end
end
if not loaded then
local veh = nil
for veh in EnumerateVehicles() do
if GetEntityModel(playerCar) == GetHashKey('bus') then
loadTxd()
loaded = true
break
end
end
end
end
end)
says it lua5.3: ...Desktop/rextester_linux_2.0/usercode/29524824/source.lua:10: unexpected symbol near ')' but I can't find it anywhere I even tried deleting the whole line 10 and pasting all the code back in and then putting the end) on line 10
There are a few syntax errors here:
The extra ) after end on line 10, which is the error you're seeing
An opening parenthesis is missing after Citizen.CreateThread
When you write function foo(...), that's equivalent to writing foo = function(...). You can't give a function a name when you're using it inline, like you are with the one you're passing to Citizen.CreateThread.
So, to fix the syntax errors, the middle part of your code (lines 10–12) should read:
...
end
Citizen.CreateThread(function(source, args, raw)
...

<name> error while trying to do two or more loops

Last time I wanted to update my LUA code to be more automatic. Earlier had to turn on and off everything manual, by deleting phrases. But I met small problem name expected near '2' error and I'm not sure what's wrong is with it. I was looking in other thread about similar error, but they didn't help me.
local BOSS = GetModConfigData("BOSS") --return true or false
local KOAL = GetModConfigData("KOAL") --return true or false
local SCULP = GetModConfigData("SCULP") --return true or false
local BossList = {"BOSS", "KOAL", "SCULP"}
local BossCode = {"bosscode", "koal_old", "koal_new", "sculp_small", "sculp_med", "sculp_big"}
k = 1
for i,v in ipairs(BossList) do
if BossList[i] == true then
if BossList[i] == "KOAL" then
for i,2 do
Bosses[k] = BossCode[k]
k = k+1
end
elseif BossList[i] == "SCULP" then
for i,3 do
Bosses[k] = BossCode[k]
k = k+1
end
else
Bosses[k] = BossCode[k]
k = k+1
end
end
end
When I'm trying to use second loop, problem comes to me. When I pushed this code without second and third loop, it was working. But without save additional BossCodes.
for i,v in ipairs(BossList) do
if BossList[i] == true then
Bosses[k] = BossCode[k]
k = k+1
end
end

How can find the missing bracket in this code?

When I run the code it tells me there's an error which is ')' expected near '=':
function restartLvl()
for i = 1, #balloonTexts do
display.remove(balloonTexts[i])
print ("restart level")
end
score.text = '0'
ballRemain.text = '3'
balloonText = {}
createBalloons(1, 3)
if (askUser.isVisible = true) then --this is the line where the error occured
askUser.isVisible = false
end
if (yesBtn.isVisible = true) then
yesBtn.isVisible = false
end
if (noBtn.isVisible = true) then
noBtn.isVisible = false
end
end
I don't know how it is still missing a ')', because I closed all the brackets.
= is the assignment operator, == is the operator to test equality. Change it to:
if (askUser.isVisible == true) then
askUser.isVisible = false
end
And all the others as well. The brackets () can be ommited for simplicity:
if askUser.isVisible == true then
askUser.isVisible = false
end
If the value is a boolean, you can also do this because all values that are not nil or false are treated as true.
if askUser.isVisible then
askUser.isVisible = false
end
This is not related to your answer but
I recommend you to use lua glider IDE because this type error can be detect well by using this IDE.

Resources