|
| 20 Jul 2016 07:44 AM |
so yea I was trying to make a script but this is what I made..
admin = {"gogomonkey69"}
if player == 1 #admin do player.NewInstance(game.Lighting.MLG)
but it doesn't work, i'm trying to give this item called "mlg" to our leader in the game, but I can't seem to do so, I just want him to have it whenever he joins the game, him and noone else but him, thanks in advance (im new to scripting and I know basically nothing about it) |
|
|
| Report Abuse |
|
|
Cinnace
|
  |
| Joined: 21 Jun 2016 |
| Total Posts: 370 |
|
|
| 20 Jul 2016 07:46 AM |
if player == 1 #admin do
what the hell
- Cinnace |
|
|
| Report Abuse |
|
|
Cinnace
|
  |
| Joined: 21 Jun 2016 |
| Total Posts: 370 |
|
|
| 20 Jul 2016 07:48 AM |
local admins = {}
local isAdmin = function(playerObj) for i,v in ipairs(admins) do if type(v) == 'number' then if playerObj.UserId == v then return true end elseif type(v) == 'string' then if playerObj.Name:lower() == v:lower() then return true end end end return false end
- Cinnace |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2016 07:52 AM |
| what does that code do? I don't need to be given something, I want to learn |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2016 07:53 AM |
| given something as in just a straight up code, I really wanna learn what it does, like break it down, its cool if you don't want to but still xD |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2016 07:55 AM |
i think you should still keep learning before doing this
'player == 1 #admin' isnt even close
|
|
|
| Report Abuse |
|
|
|
| 20 Jul 2016 07:58 AM |
well what do you think im doing im trying to learn |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2016 08:01 AM |
that code is self-explanatory just give up |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2016 08:04 AM |
local admins = {} --table of admins
local isAdmin = function(playerObj) --function isAdmin with player argument for i,v in ipairs(admins) do --loops through the admins table on the 1st line if type(v) == 'number' then --if the data in the table is a number if playerObj.UserId == v then --check if player's userID matches return true --return that player is an admin end --end if statement elseif type(v) == 'string' then --if data in the table is a string if playerObj.Name:lower() == v:lower() then --lowercase both strings and compare return true --return true if player is an admin end --end if statement end --end bigger if statement end --end loop return false --return not an admin if none of previous checks returned true end --end the function
--call it like this
isAdmin(player) |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2016 08:27 AM |
Your table is correct. "if player == 1 #admin do" What is that? Why do you need the length of the table and why is that 1 there. "player.NewInstance(game.Lighting.MLG)" I hope this is a function of your own. Also, don't use the lighting. Bad idea. Use ServerStorage or ReplicatedStorage instead.
( ͡• ◡ ͡•) -=[ RAP: 360,838 || DurstAuric; the narb of ROBLOX ]=- ( ͡• ◡ ͡•) |
|
|
| Report Abuse |
|
|
| |
|
|
| 20 Jul 2016 02:12 PM |
| so instead of lighting it would be serverstorage? |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2016 02:16 PM |
@agressiveclutch so you have this code, but lets say I only want the admin to have a specific item, such as the mlg, how would I add that to this code?
local admins = {"D3ADXxXMUS1C"} --table of admins
local isAdmin = function(playerObj) --function isAdmin with player argument for i,v in ipairs(admins) do --loops through the admins table on the 1st line if type(v) == 'number' then --if the data in the table is a number if playerObj.UserId == v then --check if player's userID matches return true --return that player is an admin end --end if statement elseif type(v) == 'string' then --if data in the table is a string if playerObj.Name:lower() == v:lower() then --lowercase both strings and compare return true --return true if player is an admin end --end if statement end --end bigger if statement end --end loop return false --return not an admin if none of previous checks returned true end --end the function |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2016 02:18 PM |
local mlg = game.Lighting.MLG -- you should use replicatedstorage or serverstorage instead btw
game.Players.PlayerAdded:connect(function(p) if not isAdmin(p) then return end p.CharacterAdded:connect(function(c) mlg:Clone().Parent = c end) end)
|
|
|
| Report Abuse |
|
|