With the TrelloAPI, I created a feedback GUI where players can type a message, and send it to my private Trello board. It worked fine, but on Trello, it wasn't getting the username, and it ended up with Sent By: Players. I wanted to get the full username, or rather, the author of the message. (The token works already, as well as the boardID, listID, and cardID.)
Here is my code found in a TextButton that sends anything that is written in a TextBox to a new card in a list on my Trello board:
ap = require(script.Parent.Parent.Parent.TrelloAPI) local Board = ap:GetBoardID("myboard") local List = ap:GetListID("test1",Board) local count = false script.Parent.MouseButton1Down:connect(function() if count == false and script.Parent.Parent.TextFrame.TextBox.Text ~= "Type here..." then wait(2) ap:AddCard(script.Parent.Parent.TextFrame.TextBox.Text,"Sent by: "..game.Players.LocalPlayer.Name,List,"","top") script.Parent.Parent.TextFrame.TextBox.Text = "Type here..." count = true for i = 240, 0, -1 do --240 seconds per feedback script.Parent.Parent.TextTimer.Text = "You can post a comment in: "..i wait(1) end count = false script.Parent.Parent.TextTimer.Text = "You can post a comment every 4 mins" else script.Parent.Parent.ReactionSound:Play() wait(.15) script.Parent.Parent.ReactionSound:Play() end end)
When I typed in some random words and hit the Send button, nothing happened. I checked the ROBLOX Developer Console (F9) and I saw this:
Players.TegraDash.PlayerGui.ScreenGui.FeedBackFrame.Enter.Script:10: attempt to index field 'Local Player' (a nil value)
Here is Line 10, same script as above:
ap:AddCard(script.Parent.Parent.TextFrame.TextBox.Text,"Sent by: "..game.Players.LocalPlayer.Name,List,"","top")
This line adds the Sent by: (player name) to the card description.
I converted it from a regular script to a Local Script to see if that solved my problem. I tested it in Studio. It worked fine. I published the game, did the same test, and it did nothing. There was no error message in the console either.
Can anyone explain the discrepancies in this?
"I converted it from a regular script to a Local Script to see if that solved my problem. I tested it in Studio. It worked fine. I published the game, did the same test, and it did nothing. There was no error message in the console either."
The reason for this is that, when testing, you are both the server and the client simultaneously, whereas when you're online, you are only the client and the server is on one of Roblox's computers.
LocalScripts only run on the client and Scripts only run on the server. Thus, as M39a9am3R says, you need to use a RemoteEvent or RemoteFunction (see Roblox API) to communicate what the client wants to the server. The server should then make sure the request is valid (ie not an exploiter/hacker sending illegal requests), and - if it's a good request - then send it off to Trello as you're doing now.