Elandorr
|
  |
| Joined: 25 Sep 2015 |
| Total Posts: 148 |
|
|
| 30 Sep 2015 04:30 PM |
Just started trying to learn remoteEvents and stuff, I get this error: Arguement 1 missing or nil. Here are the scripts;
First script, in serverScriptService in Normal Script, ------------------------------------------------- for i,v in pairs (game.Players:GetPlayers()) do if v:WaitForChild("PlayerScripts"):FindFirstChild("Starting"):FindFirstChild("DisplayMessage") then print("i") v.PlayerScripts.Starting.DisplayMessage:FireClient() end end -------------------------------------------------- Second script, in starterPlayerScripts, in local script with RemoteEvent called "DisplayMessage inside of it".
player = game.Players.LocalPlayer
local messageGui = player:WaitForChild("PlayerGui"):WaitForChild("MessageGui") local message = messageGui:WaitForChild("Message") local displayMessage = script:WaitForChild("DisplayMessage")
displayMessage.OnClientEvent:connect(function() message.Text = "Game Is Starting" end)
|
|
|
| Report Abuse |
|
|
Elandorr
|
  |
| Joined: 25 Sep 2015 |
| Total Posts: 148 |
|
|
| 30 Sep 2015 04:31 PM |
| Oh the error is on the line below print("i") |
|
|
| Report Abuse |
|
|
|
| 30 Sep 2015 04:31 PM |
You have to tell the server which player to fire the event to. remoteEvent:FireClient(player)
morashsPeasant is n0 sk0p1ng |
|
|
| Report Abuse |
|
|
Elandorr
|
  |
| Joined: 25 Sep 2015 |
| Total Posts: 148 |
|
|
| 30 Sep 2015 04:34 PM |
| Ty! Anything else I should be aware of with Remote stuff. First time using it. |
|
|
| Report Abuse |
|
|
|
| 30 Sep 2015 04:37 PM |
Note: when using RemoteFunctions, you cant return instances that arent parented to anything.
For example:
local prt = Instance.new("Part") prt.Name = "Yay" return prt
That wont work. You will have to parent it to something (lighting works) and then remove it later.
(Also note I might be wrong about this, but in the past Ive had to parent Instances) |
|
|
| Report Abuse |
|
|
Elandorr
|
  |
| Joined: 25 Sep 2015 |
| Total Posts: 148 |
|
|
| 30 Sep 2015 04:39 PM |
| Ty. So should I be using Remote stuff to be able to access player from serverScripts such as changing Gui's or give tools? |
|
|
| Report Abuse |
|
|
|
| 30 Sep 2015 04:43 PM |
Yes. But keep in mind that the client can read from the server, but not make changes. So, you dont need a whole remote event/function cycle to get the size of a brick in workspace.
A local script can reference anything as long as it doesn't make changes.
The same can't be said for a server script. If you want the server to make changes to GUIs youll have to have an event. But the server can move characters and change leaderstats, as they are in the server. |
|
|
| Report Abuse |
|
|
Elandorr
|
  |
| Joined: 25 Sep 2015 |
| Total Posts: 148 |
|
|
| 30 Sep 2015 04:45 PM |
| Ok, ty. I'm making a game and since my coding works but is very poorly coded and very glitchy Im trying to improve it |
|
|
| Report Abuse |
|
|