Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How come my admin commands won't work?

So I am making admin commands and they work fine in roblox studio but when I try to use them in like Script Builder or My game they don't work...

Script:

local Admins = {["silverminer226"] = true, ["Player"] = true, ["RLuaScripting"] = true}
 
function onChatted(message, player)
    if message == "create/Part" and Admins[player.Name] then
       a = Instance.new("Part", workspace)
    end
end
 
game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(message) onChatted(message, player) end)
end)

I asked some people and they said it needed to be client sided and I have no clue how to do that xD

5 comments

0

It means use a localscript ._.

0

Don't work :P

0

You can't make it a LocalScript because it uses game.Players.PlayerAdded event. You need to record chats from the Local Player.

0

I'll try that.

0

There are some things that could be better but I see nothing that would prevent it working.

2 answers

Personally, I don't see why it needs to be client-sided. It is very limiting.

Also, I will make the script better/more efficient:

local admins = {
	[¨PlayerName¨] == true -- you dont need to do Player or your username, because this script does it for you
}

game.Players.PlayerAdded:connect(function(p)
	if admins[p.Name] or p.UserId == game.OwnerId then -- your userId is the same when youre Player
		p.Chatted:connect(function(msg)
			if msg == ¨create/part¨ then
				local a = Instance.new(¨Part¨)
				a.Parent = game.Workspace -- simply defining a local does not create a part, i think
			end
		end)
	end
end)

This should work.

2 comments

0

Worked on roblox studio not on the game

0

Is this is a script in Workspace? and re-copy the code, I changed it

I don't think so guys, About those Comments, As far as i know, I made this: http://www.roblox.com/Nathans-Simple-Admin-Commands-Script-item?id=322960285 "Local Won't really make it work, Since from what i know FilteringEnabled, it would only make it for that client, and not globally on the server." First. Does your game have FilteringEnabled Set to True or False? if False, I may not be able to help you, If true

Try the script i have there, Making the part code was correct. Just, Let's say, Maybe you want it to be positioned where the people stands at? Well, There goes the problem, You have to get a Vector3 of the Torso that the player Executed, and take its Location, and position the part to it. You did it using only Instance.new Which automatically positions them to the Vector 3 of 0,0,0

TL;DR The Code Sounds Right, But with Direct Instance.New, it's auto-positioned to 0,0,0

Excuse my English :P

1 comment

0

I'll try this out :)

This discussion is preserved as it was. New answers, comments, and votes are closed.