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

why do i get argument 1 missing or nil?

Asked by 5 years ago

when i say admin in chat it just give me 14:50:27.994 - Argument 1 missing or nil

14:50:27.995 - Stack Begin

14:50:27.996 - Script 'Players.world_kiIIer.Backpack.wk admin', Line 14

14:50:27.997 - Stack End

here is my local script:

local rep = game:GetService("ReplicatedStorage")

local admin = rep:WaitForChild("admin")

local noadmin = rep:WaitForChild("noadmin")

local player = game.Players.LocalPlayer



player.Chatted:Connect(function(msg)

if player.Name ~= "world_kiIIer" then return end

if msg:lower() == "admin" then

admin:FireClient()

end

end)

1 answer

Log in to vote
0
Answered by 5 years ago
Edited by User#24403 5 years ago

First off, please identify if you script is a LocalScript or Script. This will help us much more.

If it is a LocalScript you can't FireClient() because you already are the client. What you are looking for is :FireServer().

If this is a Script. The variable Player will be nil because you can not do LocalPlayer on the server.

Overall, dealing with admins is a very serious thing and should be properly scripted to avoid exploits. Right now if it's on the client you're letting anyone just hack into it and use all the commands.

What I suggest is a PlayerAdded event on the server to get the player and then use a Chatted event.

Anyway, If you still insist on letting people hack your client script then simply change FireClient() to FireServer()

Best of luck developer! Hope this helped.

BlackOrange3343

0
This is a local script i forgot to include that. I did look up fireclient and saw roblox’s script on the player added function but i got no success Gameplayer365247v2 1055 — 5y
0
That's because PlayerAdded should be in a ServerScript BlackOrange3343 2676 — 5y
0
When dealing with admin commands we should never use LocalScripts unless you have a UI for it BlackOrange3343 2676 — 5y
0
Could you please edit your question to include the code you added? LisaF854 93 — 5y
0
This is a answer, not a question. The question is above BlackOrange3343 2676 — 5y
Ad

Answer this question