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

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.

Related

roblox studio: TextBox.Text returns ""

I was making custom chat system and I faced this "bug".
just textbox returns "", not nil.
and there is no any error. even without
string.len(script.Parent.Parent.message.Text) > 0
"if" part.
local db = false
local TextService = game:GetService("TextService")
script.Parent.MouseButton1Click:Connect(function ()
local plr = script.Parent.Parent.Parent.Parent.Parent.Parent
local dn = plr.Character.Humanoid.DisplayName
local muted = script.Parent.muted.Value
local mod = script.Parent.moderator.Value
if db == false and muted == false and string.len(script.Parent.Parent.message.Text) > 0 then
db = true
local ts = 16
local msg = script.Parent.Parent.chat.message0:Clone()
--problem line
msg.messageContent.Text = TextService:FilterStringAsync(script.Parent.Parent.message.Text, plr.UserId, "2")
if string.len(script.Parent.Parent.message.Text) > 130 then
ts = 14
end
msg.messageContent.TextSize = ts
--problem ends
local ps = msg.prefixes
ps.bot.Visible = false
local counter = game.ReplicatedStorage.ChatBlockStorage.counter.Value
msg.Name = "message" .. counter
msg.actualName.Text = "#" .. plr.Name
msg.displayName.Text = dn
msg.icon.Image = game.Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
msg.icon.ResampleMode = "Default"
if script.Parent.Parent.message.customIcon.locked.Visible == false then
msg.icon.Image = "http://www.roblox.com/asset/?id=" .. script.Parent.Parent.message.customIcon.Text
end
if msg.Name == "message1" then
mod = true
end
if mod == true then
ps.mod.Visible = true
end
counter += 1
script.Parent.Parent.message.Text = ""
wait(game.ReplicatedStorage.ChatBlockStorage.waitTime.Value)
db = false
end
end)
any ideas how to fix it?
Use the FocustLost event. Here is the roblox documentation on it.
Example:
script.Parent.FocusLost:Connect(function(enterPressed)
if enterPressed then
print("Focus was lost because enter was pressed!")
end
end)
Near the end of the code, you write
script.Parent.Parent.message.Text = ""
Would this not be the cause?
maybe you can do tostring(msg)?
this prob wont work
tostring("i like beans")
read more on strings here:https://developer.roblox.com/en-us/articles/String
read more on tostring() here: https://devforum.roblox.com/t/what-does-assert-and-tostring-do/1047653
(none are people i know but i looked through them and they have valid info)
good luck my brother

Why does Roblox & Roblox Studio both crash when running certain scripts with no error code?

So here's the deal, I'm working on a game that is similar to a murder mystery and this part of the system is to start the round and show the players their roles and then the map. Except it used to work and I didn't knowingly do anything to the scripts that would affect it so the game crashes when this part is carried out. All I know is it starts to display the role and often does, it also plays the sound and displays the correct description, however it crashes just after that and sometimes just before the role is revealed. I've attached the function that runs when the RoundStarter event is fired to the client.
The server doesn't crash but, all of the clients do but not all at the exact same moment in time; Previously when there has been errors, I've been able to identify an error message but none of the clients throw any clear issues.
In testing mode in Roblox Studio, they freeze just after the drum roll sound effect as the role is displayed, however no errors and the server seems to be acting normally. Near enough the same thing happens when ran in Roblox.
Clientside script
ReplicatedStorage.Players.Events.RoundStarter.OnClientEvent:Connect(function(Role,Map)
local player = game.Players.LocalPlayer
player.CameraMode = Enum.CameraMode.LockFirstPerson
script.Parent.RoundGui.RoundEnd.Visible = false
game.Players.LocalPlayer.NameDisplayDistance = 0
CURRENTROLE = Role
CURRENTMAP = Map
script.Parent.RoundGui.Enabled = true
script.Parent.RoundGui.RoundStarter.Visible = true
script.Parent.RoundGui.RoundStarter.Fader.Visible = true
script.Parent.RoundGui.RoundStarter.Fader.BackgroundTransparency = 0
script.Parent.RoundGui.RoundStarter.RoleDescription.Visible = false
script.Parent.RoundGui.RoundStarter.RoleName.Visible = false
script.Parent.RoundGui.RoundStarter.Text.Visible = true
local transp = 0
for i = 1,50,1 do
transp += 0.05
script.Parent.RoundGui.RoundStarter.Fader.BackgroundTransparency = transp
wait(.1)
end
script.Parent.RoundGui.RoundStarter.DR:Play()
script.Parent.RoundGui.RoundStarter.RoleName.Visible = true
script.Parent.RoundGui.RoundStarter.RoleName.Text = Role
script.Parent.RoundGui.RoundStarter.RoleDescription.Visible = true
if Role == "Civilian" then
script.Parent.RoundGui.RoundStarter.RoleDescription.Text = "Your Job is to help the Inspector find the shadow... Work to figure them out and stop them before it's too late! Don't tell anyone your Role!"
script.Parent.RoundGui.RoundStarter.RoleName.TextColor3 = Color3.fromRGB(0, 255, 17)
elseif Role == "Shadow" then
script.Parent.RoundGui.RoundStarter.RoleName.TextColor3 = Color3.fromRGB(255, 0, 0)
script.Parent.RoundGui.RoundStarter.RoleDescription.Text = "It's time... Infiltrate the crowd, gain their trust and kill the inspector to win! By killing another player, You can take on their form and blend in with the Civilians. More help will be on left of the screen. Don't tell anyone your Role!"
elseif Role == "Inspector" then
script.Parent.RoundGui.RoundStarter.RoleName.TextColor3 = Color3.fromRGB(0, 38, 255)
script.Parent.RoundGui.RoundStarter.RoleDescription.Text = "You are nominated to fight the Shadow and eliminate them. You must work with the Civilians to figure out who the Shadow is, if you die you lose. Don't tell anyone your Role!"
end
wait(10)
script.Parent.RoundGui.RoundStarterMap.Visible = true
script.Parent.RoundGui.RoundStarterMap.Fader.Visible = true
script.Parent.RoundGui.RoundStarterMap.MapDescription.Visible = false
script.Parent.RoundGui.RoundStarterMap.MapName.Visible = false
local transp = 0
for i = 1,50,1 do
transp += 0.05
script.Parent.RoundGui.RoundStarterMap.Fader.BackgroundTransparency = transp
wait(.1)
end
script.Parent.RoundGui.RoundStarterMap.MapName.Visible = true
script.Parent.RoundGui.RoundStarterMap.MapName.Text = Map
script.Parent.RoundGui.RoundStarter.Dun:Play()
if Map == "The Office" then
script.Parent.RoundGui.RoundStarterMap.MapDescription.Text = "A classic map based in an Office building, in a power cut, near midnight. With an outdoor and Indoor area to explore, will you survive?"
elseif Map =="The Village" then
script.Parent.RoundGui.RoundStarterMap.MapDescription.Text = "The original map based in a small villiage with numerous buildings and areas to explore."
end
script.Parent.RoundGui.RoundStarterMap.MapDescription.Visible = true
wait(10)
script.Parent.RoundGui.RoundEnd.Visible = false
script.Parent.RoundGui.RoundStarterMap.Visible = false
script.Parent.RoundGui.RoundStarter.Visible = false
end)
--This is the next function in the code that should be executed at a similar time to the above one (It should have an InMap value of true.
ReplicatedStorage.Players:WaitForChild(player.Name).InMap.Changed:Connect(function()
data = game.ReplicatedStorage.GetPlayerDataCS:InvokeServer()
if ReplicatedStorage.Players[player.Name].InMap.Value == false then
--StartGUI:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
player.CameraMode = Enum.CameraMode.Classic
--StartGUI:SetCoreGuiEnabled(Enum.CoreGuiType.Chat,true)
script.Parent.LobbyGui.Enabled = true
script.Parent.RoundGui.Enabled = false
wait()
else
if CURRENTROLE == "Shadow" then
script.Parent.RoundGui.ShadowPanel.Visible = true
script.Parent.RoundGui.CivPanel.Visible = false
script.Parent.RoundGui.InsPanel.Visible = false
if data then
if data.EquippedAbility ~="None" and data.EquippedAbility ~="" then
script.Parent.RoundGui.ShadowPanel[data.EquippedAbility].Visible = true
end
end
elseif CURRENTROLE == "Inspector" then
script.Parent.RoundGui.ShadowPanel.Visible = false
script.Parent.RoundGui.CivPanel.Visible = false
script.Parent.RoundGui.InsPanel.Visible = true
else
script.Parent.RoundGui.ShadowPanel.Visible = false
script.Parent.RoundGui.CivPanel.Visible = true
script.Parent.RoundGui.InsPanel.Visible = false
end
--StartGUI:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
--StartGUI:SetCoreGuiEnabled(Enum.CoreGuiType.Chat,true)
script.Parent.LobbyGui.Enabled = false
script.Parent.RoundGui.Enabled = true
wait()
end
end)
Here's also the script on the server that should be near the event.
local replicatedstor = game:GetService("ReplicatedStorage")
local playersinthemap = {}
local playersinserver = game.Players:GetPlayers()
local maplist = {"The Village"}
local TESTINGMODE = false
local goodwin = false
local COUNT = 0
local deadpool = {}
local DataStoreService = game:GetService("DataStoreService")
local Datastore = DataStoreService:GetDataStore("THE_MASQUERADE_TEST2")
function UpdateStatuses(Playerr,NewStatus)
local c = Playerr
if NewStatus == "Lobby" or NewStatus == "AFK" then
if game.ReplicatedStorage.Players[c.Name].Status.Value == "Shadow" then
script.RoundsInProgress.Value = false
goodwin = true
elseif game.ReplicatedStorage.Players[c.Name].Status.Value == "Inspector" then
script.RoundsInProgress.Value = false
goodwin = false
end
game.ReplicatedStorage.Players[c.Name].InMap.Value = false
if table.find(playersinthemap,c,1)~= nil then
local index = table.find(playersinthemap,c,1)
table.remove(playersinthemap,index)
end
end
game.ReplicatedStorage.Players[c.Name].Status.Value = NewStatus
if #playersinthemap <= 2 and script.RoundsInProgress.Value == true then
script.RoundsInProgress.Value = false
goodwin = false
end
end
game.ReplicatedStorage.Players.Events.SetStatus.OnServerEvent:Connect(function(Player,Status)
if Status ~= nil then
UpdateStatuses(Player,Status)
else
print ("Tried to change status of Player but the given status was nil.")
end
end)
while true do
while script.RoundsRunning.Value == true do
game.ReplicatedStorage.Players.Events.Notify:FireAllClients("Intermission...","L",false)
--game.ReplicatedStorage.Game.Intermission:Fire(30)
--game.ReplicatedStorage.Game.Intermission.Event:Wait()
wait(35)
game.Workspace.Lobby.DATABOARD.SurfaceGui.Frame.Title.Text = "Round starting soon..."
--game.ReplicatedStorage.Players.Events.Notify:FireAllClients("Round starting soon...","L",true)
--game.Workspace.Lobby.DATABOARD.SurfaceGui.Frame.Time.Text = ""
if not game.Workspace.Map then
playersinthemap = {}
local Mapfolder = Instance.new("Folder",game.Workspace)
Mapfolder.Name = "Map"
end
playersinserver = game.Players:GetPlayers()
wait(10)
playersinserver = game.Players:GetPlayers()
if #playersinserver >= 4 or (TESTINGMODE == true and #playersinserver >= 3) then
game.Workspace.Lobby.DATABOARD.SurfaceGui.Frame.Title.Text = "Round loading..."
game.ReplicatedStorage.Players.Events.Notify:FireAllClients("Loading the round now...","L",false)
playersinserver = game.Players:GetPlayers()
local chosenMapIndex = math.random(#maplist)
local chosenMapName = maplist[chosenMapIndex]
local chosenShadowIndex = math.random(#playersinserver)
local chosenShadow = playersinserver[chosenShadowIndex]
local chosenInspectorIndex = math.random(#playersinserver)
local chosenInspector = playersinserver[chosenInspectorIndex]
while chosenInspector == chosenShadow do
chosenInspectorIndex = math.random(#playersinserver)
chosenInspector = playersinserver[chosenInspectorIndex]
end
local playernumber = playersinserver
COUNT = 0
while COUNT ~= #playersinserver do
COUNT += 1
local playername = playersinserver[COUNT].Name
print (playersinserver)
print ("Player trying to send role data:"..playername)
if playersinserver[COUNT] == chosenShadow then
game.ReplicatedStorage.Players.Events.RoundStarter:FireClient(playersinserver[COUNT],"Shadow",chosenMapName)
game.ReplicatedStorage.Players[playersinserver[COUNT].Name].Status.Value = "Shadow"
--temp = game.ReplicatedStorage.ReadStatus:Invoke(playername,"Shadow")
elseif playersinserver[COUNT] == chosenInspector then
game.ReplicatedStorage.Players.Events.RoundStarter:FireClient(playersinserver[COUNT],"Inspector",chosenMapName)
game.ReplicatedStorage.Players[playersinserver[COUNT].Name].Status.Value = "Inspector"
--temp = game.ReplicatedStorage.ReadStatus:Invoke(playername,"Inspector")
else
game.ReplicatedStorage.Players.Events.RoundStarter:FireClient(playersinserver[COUNT],"Civilian",chosenMapName)
game.ReplicatedStorage.Players[playersinserver[COUNT].Name].Status.Value = "Civilian"
--temp = game.ReplicatedStorage.ReadStatus:Invoke(playername,"Civilian")
end
end
wait()
local MapInServerStorage = game.ServerStorage.Maps:FindFirstChild(chosenMapName)
local LoadedMap = MapInServerStorage:Clone()
LoadedMap.Parent = game.Workspace.Map
local spawns = {}
for i,c in pairs(LoadedMap:GetDescendants()) do
if c.Name == "Spawn" then
table.insert(spawns,1,c)
end
end
COUNT = 0
local i = COUNT
while COUNT ~= #playersinserver do
COUNT += 1
print ("Setting Character locations. Loop:"..COUNT)
local spawnlistindex = math.random(#spawns)
playersinserver[COUNT].Character:SetPrimaryPartCFrame(spawns[spawnlistindex].CFrame)
--playersinserver[COUNT].Character:SetPrimaryPartCFrame(LoadedMap.Spawns.Spawn.CFrame)
table.insert(playersinthemap,1,playersinserver[COUNT])
playersinserver[COUNT].NameDisplayDistance = 0
game.ReplicatedStorage.Players:FindFirstChild(playersinserver[COUNT].Name).InMap.Value = true
if playersinserver[COUNT] == chosenInspector then
local data = game.ReplicatedStorage.GetPlayerData:Invoke(chosenInspector)
Pistl = game.ServerStorage.Guns[data.EquippedSkin]:Clone()
Pistl.Parent = playersinserver[COUNT].Backpack
end
end
print ("Round starting...")
--This is then followed by the rest of the round system which should be working but I have cut it to try to shorten the amount of reading but can be supplied if needed. It is closed correctly.
I've tried to keep the code to a minimum however it could be anywhere and as there are no obvious script related error codes, I'm requesting some assistance in some way.
There are other things that may have caused it but this is becoming a real issue, especially since it used to work, and I've included all of the likely suspects but I'm happy to give anything else if these aren't incorrect in anyway.
If you wish to see what happens yourself, you'll need either 4 Roblox Accounts or 3 extra friends.
Here's the game on Roblox: The Masquerade
If anything else is needed, feel free to let me know and thanks for reading and any potential help. (Just so you know, I have done a lot of research on all of the functions and things I'm using but I can't find any issues, it just freezes & crashes).
The only error codes I've got are:
Start Process Exception...
Uploading crash analytics
Done uploading crash analytics
There are some random wait() statements without any arguments, which shouldn't be in your code anyway. This may very well hang up the server / client.
Also, you appear to have a few while loops which do not have any wait()'s. That's a pretty common problem which stalls the client executing the script. Try adding at least
wait(0.01) to the end of each while true loop that doesn't have it already.
There might be some occurences of this in the client as well (like that one lonely wait() with no parameters), but here's a modified version of your server script:
while true do
while script.RoundsRunning.Value == true do
game.ReplicatedStorage.Players.Events.Notify:FireAllClients("Intermission...","L",false)
--game.ReplicatedStorage.Game.Intermission:Fire(30)
--game.ReplicatedStorage.Game.Intermission.Event:Wait()
wait(35)
game.Workspace.Lobby.DATABOARD.SurfaceGui.Frame.Title.Text = "Round starting soon..."
--game.ReplicatedStorage.Players.Events.Notify:FireAllClients("Round starting soon...","L",true)
--game.Workspace.Lobby.DATABOARD.SurfaceGui.Frame.Time.Text = ""
if not game.Workspace.Map then
playersinthemap = {}
local Mapfolder = Instance.new("Folder",game.Workspace)
Mapfolder.Name = "Map"
end
playersinserver = game.Players:GetPlayers()
wait(10)
playersinserver = game.Players:GetPlayers()
if #playersinserver >= 4 or (TESTINGMODE == true and #playersinserver >= 3) then
game.Workspace.Lobby.DATABOARD.SurfaceGui.Frame.Title.Text = "Round loading..."
game.ReplicatedStorage.Players.Events.Notify:FireAllClients("Loading the round now...","L",false)
playersinserver = game.Players:GetPlayers()
local chosenMapIndex = math.random(#maplist)
local chosenMapName = maplist[chosenMapIndex]
local chosenShadowIndex = math.random(#playersinserver)
local chosenShadow = playersinserver[chosenShadowIndex]
local chosenInspectorIndex = math.random(#playersinserver)
local chosenInspector = playersinserver[chosenInspectorIndex]
while chosenInspector == chosenShadow do
chosenInspectorIndex = math.random(#playersinserver)
chosenInspector = playersinserver[chosenInspectorIndex]
end
local playernumber = playersinserver
COUNT = 0
while COUNT ~= #playersinserver do
COUNT += 1
local playername = playersinserver[COUNT].Name
print (playersinserver)
print ("Player trying to send role data:"..playername)
if playersinserver[COUNT] == chosenShadow then
game.ReplicatedStorage.Players.Events.RoundStarter:FireClient(playersinserver[COUNT],"Shadow",chosenMapName)
game.ReplicatedStorage.Players[playersinserver[COUNT].Name].Status.Value = "Shadow"
--temp = game.ReplicatedStorage.ReadStatus:Invoke(playername,"Shadow")
elseif playersinserver[COUNT] == chosenInspector then
game.ReplicatedStorage.Players.Events.RoundStarter:FireClient(playersinserver[COUNT],"Inspector",chosenMapName)
game.ReplicatedStorage.Players[playersinserver[COUNT].Name].Status.Value = "Inspector"
--temp = game.ReplicatedStorage.ReadStatus:Invoke(playername,"Inspector")
else
game.ReplicatedStorage.Players.Events.RoundStarter:FireClient(playersinserver[COUNT],"Civilian",chosenMapName)
game.ReplicatedStorage.Players[playersinserver[COUNT].Name].Status.Value = "Civilian"
--temp = game.ReplicatedStorage.ReadStatus:Invoke(playername,"Civilian")
end
end
-- wait() useless wait
local MapInServerStorage = game.ServerStorage.Maps:FindFirstChild(chosenMapName)
local LoadedMap = MapInServerStorage:Clone()
LoadedMap.Parent = game.Workspace.Map
local spawns = {}
for i,c in pairs(LoadedMap:GetDescendants()) do
if c.Name == "Spawn" then
table.insert(spawns,1,c)
end
end
COUNT = 0
local i = COUNT
while COUNT ~= #playersinserver do
COUNT += 1
print ("Setting Character locations. Loop:"..COUNT)
local spawnlistindex = math.random(#spawns)
playersinserver[COUNT].Character:SetPrimaryPartCFrame(spawns[spawnlistindex].CFrame)
--playersinserver[COUNT].Character:SetPrimaryPartCFrame(LoadedMap.Spawns.Spawn.CFrame)
table.insert(playersinthemap,1,playersinserver[COUNT])
playersinserver[COUNT].NameDisplayDistance = 0
game.ReplicatedStorage.Players:FindFirstChild(playersinserver[COUNT].Name).InMap.Value = true
if playersinserver[COUNT] == chosenInspector then
local data = game.ReplicatedStorage.GetPlayerData:Invoke(chosenInspector)
Pistl = game.ServerStorage.Guns[data.EquippedSkin]:Clone()
Pistl.Parent = playersinserver[COUNT].Backpack
end
wait(0.01)
end
wait(0.01)
end
These are just the rough steps, so implant the changes in your code the way you want them to be.

<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

Syntax error: player.lua:11: '=' expected near '<eof>'

I have recently been learning Lua with Love2d, so I decided to start making a simple RPG. It's quite simple. The console is where you play, and the extra window is where you can see your stats, equip items, ect.
But, I have run into a problem! Whenever I run the code, I see this main.lua:15: '=' expected near 'else'
I will include the code (all 3 files) below.
This is main.lua
function love.load()
love.graphics.setBackgroundColor( 255, 255, 255 )
require("player")
print("Enter your name")
pcStats.Name = io.read()
print("What class are you, " .. pcStats.Name .. "?")
pcStats.Class = io.read()
if pcStats.Class == "Ranger" then
os.execute("cls")
pcInv.InvSpace = 10
pcInv.Items.basicBow = Basic Bow
else
print("Error: Invalid Class. Please restart game")
end
print("What would you like to do? CODE END")
input = io.read()
end
function love.draw()
love.graphics.setColor( 0, 0, 0 )
love.graphics.print( "Level: " .. pcStats.Level, 1, 1 )
love.graphics.print( "Inv Space: " .. pcInv.InvSpace, 1, 20 )
love.graphics.print( "Inv: " .. pcInv.Items, 1, 40 )
end
Here is player.lua This is where the game variables are stored
pcStats = {}
pcStats.Level = 1
pcStats.XP = nil
pcStats.Name = nil
pcStats.Class = nil
pcStats.Atk = nil
pcStats.Def = nil
pcInv = {}
pcInv.InvSpace = nil
pcInv.Items.testsword = testing sword
And last but not least, here is the conf.lua used for love2d
function love.conf(t)
t.modules.joystick = true
t.modules.audio = true
t.modules.keyboard = true
t.modules.event = true
t.modules.image = true
t.modules.graphics = true
t.modules.timer = true
t.modules.mouse = true
t.modules.sound = true
t.modules.thread = true
t.modules.physics = true
t.console = true
t.title = "Lua RPG Alpha v0.0.1"
t.author = "Zach Herzer"
end
Line 15 is this:
pcInv.Items.basicBow = Basic Bow
Basic Bow isn't valid Lua code. I am pretty sure you meant something else - perhaps a string?
pcInv.Items.basicBow = "Basic Bow"
While we're at it,
pcInv.Items.testsword = testing sword
has a similar problem.

Cloning+Dragging model when button is click ROBLOX [LUA]?

So I thought of having this for so long, I just don't know where to start. I am new to this language and I keep learning, but kind of hard for me. But I have built my very own custom character which took 2 weeks for me. Anyway, For my question. An example is if I have a button and I click it, a model will be clone and I can drag that model and put it anywhere nearby. What possible method I can use to achieve this?
First things first, I suggest for any future questions, you head over to https://scriptinghelpers.org/
now, on to your question, for cloning the model, you should use mouse.Target.Parent:Clone() or the GetTopParent(mouse.Target) function in my function library (which you can get here; http://www.roblox.com/item.aspx?id=244244638)
then deposit the model into workspace and MakeJoints()
the next step is to move the model, this can be tricky, but the simplest method is model:MoveTo(mouse.Hit.p) on mouse.Moved (but that's a little buggy)
Another method for movement would be to use the Handles class, but I'm not really familiar with it, so you'd have to figure that one out on your own.
To make the first method less buggy, I'd suggest something along the lines of
model:MoveTo(mouse.Hit.p.X, mouse.Target.Position.Y + (model:GetExtentsSize().Y / 2), mouse.Hit.p.Z)
but you'd have to set up the mouse to ignore the model, which I can't really help with.
A really good place to start is to search the free models in Studio Toolbox for a 'Dragger Tool' or 'Model Dragger Tool' and then use the script inside to get started creating your own. I have learned to create my own custom draggers by doing this and it is way easier than you may think at first. Once you find a good dragger tool to borrow code from, if you need to enhance it, you can find the dragger api in the Roblox Wiki to help you further customize it to your specific needs.
http://wiki.roblox.com/index.php?title=API:Class/Dragger
EDIT: So here's the first dragger script that showed when I searched. It will drag models and parts but you will have to edit it to meet your requirements using the dragger api. Create a Tool in player.BackPack then create a LocalScript inside the Tool then copy and paste the code below into the LocalScript, and that will get you started.
local Tool = script.Parent
enabled = true
local origTexture = Tool.TextureId
game:GetService("ContentProvider"):Preload("rbxasset://icons/freemove_sel.png")
local selectionBox
local currentSelection
local currentSelectionColors = {}
local selectionLasso
local inGui = false
local inPalette = false
local lockTime = 0
function canSelectObject(part)
return part and not (part.Locked) and (part.Position - script.Parent.Parent.Head.Position).Magnitude < 60
end
function findModel(part)
while part ~= nil do
if part.className == "Model" then
return part
end
part = part.Parent
end
return nil
end
function startDrag(mousePart, hitPoint, collection)
dragger = Instance.new("Dragger")
pcall(function() dragger:MouseDown(mousePart, hitPoint, collection) end)
end
function collectBaseParts(object, collection)
if object:IsA("BasePart") then
collection[#collection+1] = object
end
for index,child in pairs(object:GetChildren()) do
collectBaseParts(child, collection)
end
end
function onMouseDown(mouse)
mouse.Icon ="rbxasset://textures\\GrabRotateCursor.png"
local part = mouse.Target
if canSelectObject(part) then
local hitPoint = mouse.Hit:toObjectSpace(part.CFrame).p
if trySelection(part) then
local instances = {}
collectBaseParts(currentSelection, instances)
startDrag(part, hitPoint, instances)
return
end
end
--Clear the selection if we weren't able to lock succesfullu
onMouseUp(mouse)
end
function onMouseUp(mouse)
mouse.Icon ="rbxasset://textures\\GrabCursor.png"
if dragger ~= nil then
pcall(function() dragger:MouseUp() end)
dragger = nil
end
end
function trySelection(part)
if canSelectObject(part) then
selectionLasso.Part = part
local model = findModel(part)
if model then
return setSelection(model)
else
return setSelection(part)
end
else
clearSelection()
return false
end
end
function onKeyDown(key)
if dragger ~= nil then
if key == 'R' or key == 'r' then
dragger:AxisRotate(Enum.Axis.Y)
elseif key == 'T' or key == 't' then
dragger:AxisRotate(Enum.Axis.Z)
end
end
end
local alreadyMoving
function onMouseMove(mouse)
if alreadyMoving then
return
end
alreadyMoving = true
if dragger ~= nil then
--Maintain the lock
if time() - lockTime > 3 then
Instance.Lock(currentSelection)
lockTime = time()
end
--Then drag
pcall(function() dragger:MouseMove(mouse.UnitRay) end)
else
trySelection(mouse.Target)
end
alreadyMoving = false
end
function saveSelectionColor(instance)
if instance:IsA("BasePart") then
currentSelectionColors[instance] = instance.BrickColor
if instance.BrickColor == BrickColor.Blue() then
instance.BrickColor = BrickColor.new("Deep blue")
else
instance.BrickColor = BrickColor.Blue()
end
end
local children = instance:GetChildren()
if children then
for pos, child in pairs(children) do
saveSelectionColor(child)
end
end
end
function setSelection(partOrModel)
if partOrModel ~= currentSelection then
clearSelection()
if Instance.Lock(partOrModel) then
lockTime = time()
currentSelection = partOrModel
saveSelectionColor(currentSelection)
selectionBox.Adornee = currentSelection
return true
end
else
if currentSelection ~= nil then
if time() - lockTime > 2 then
--Maintain the lock
if not(Instance.Lock(currentSelection)) then
--we lost the lock
clearSelection()
return false
else
lockTime = time()
return true
end
else
return true
end
end
end
return false
end
function clearSelection()
if currentSelection ~= nil then
for part, color in pairs(currentSelectionColors) do
part.BrickColor = color
end
selectionBox.Adornee = nil
Instance.Unlock(currentSelection)
end
currentSelectionColors = {}
currentSelection = nil
selectionLasso.Part = nil
selectionBox.Adornee = nil
end
function onEquippedLocal(mouse)
Tool.TextureId = "rbxasset://icons/freemove_sel.png"
local character = script.Parent.Parent
local player = game.Players:GetPlayerFromCharacter(character)
inGui = false
inPalette = false
mouse.Icon ="rbxasset://textures\\GrabCursor.png"
mouse.Button1Down:connect(function() onMouseDown(mouse) end)
mouse.Button1Up:connect(function() onMouseUp(mouse) end)
mouse.Move:connect(function() onMouseMove(mouse) end)
mouse.KeyDown:connect(function(string) onKeyDown(string) end)
selectionBox = Instance.new("SelectionBox")
selectionBox.Name = "Model Delete Selection"
selectionBox.Color = BrickColor.Blue()
selectionBox.Adornee = nil
selectionBox.Parent = player.PlayerGui
selectionLasso = Instance.new("SelectionPartLasso")
selectionLasso.Name = "Model Drag Lasso"
selectionLasso.Humanoid = character.Humanoid
selectionLasso.archivable = false
selectionLasso.Visible = true
selectionLasso.Parent = game.workspace
selectionLasso.Color = BrickColor.Blue()
alreadyMoving = false
end
function onUnequippedLocal()
Tool.TextureId = origTexture
clearSelection()
selectionBox:Remove()
selectionLasso:Remove()
end
Tool.Equipped:connect(onEquippedLocal)
Tool.Unequipped:connect(onUnequippedLocal)

Resources