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

Help with onChatted Comand script?

Hi. Thanks for the help. I am making a Simple Admin Script using chatted events. I am testing it by making a command where it gives u a bighead just to test it. There was 2 things wrong with it anything u said it would give u a bighead and Its not supposed to do that. 2. The admin didn't work because anyone could do it. So heres the script:)

local Admins = {"iSvenDerp"}


function checkAuthority(name)
	for a,v in pairs(Admins) do
		if v == name then
			return true 
		end
	end
	return false
end




game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if msg == "bighead" or "Bighead" then
            player.Character.Head.Mesh.Scale = Vector3.new(3,3,3)
        
        end
    end)
end)

1 answer

✓ Accepted answer

##The Problem Your problem is that you're not calling the function at all. Also, for being able to say anyword, you didn't restate your condition. If you have it say:

if msg="bighead" or "Bighead" then

it's pretty much saying if the string "Bighead" is true, then allow it. To fix that, you need to completely restate the condition.


##Fix Here's a pretty simple fix:

local Admins = {"iSvenDerp"}


function checkAuthority(name)
	for a,v in pairs(Admins) do
		if v == name then
			return true 
		end
	end
	return false
end




game.Players.PlayerAdded:connect(function(player)
	player.Chatted:connect(function(msg)
		if (msg == "bighead" or msg == "Bighead") and checkAuthority(player.Name) then --Called the function and restated condition
			player.Character.Head.Mesh.Scale = Vector3.new(3,3,3)
		end
	end)
end)

So that's pretty much it. You had everything else correct, you just needed to call the function for it to work right.


Anyways, if you have any further problems/questions, please leave a comment below. Hope I helped :P

####-Dyler3

6 comments

0

Thanks u answered 1 of my 2 questions! The admin part works but still if I say anyword it gives me a big head

0

Ah, sorry about that. Try it now, and it should work.

0

ok

0

Thanks! Accepted and upvoted:)

0

No problem. Glad I could help :P

1

A more efficient way is to check if the player's an admin as soon as they join the game, that way if they're not an admin the chatted event won't even be listened for.

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