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

Help with onChatted Comand script?

Asked by
iSvenDerp 233 Moderation Voter
9 years ago

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

Log in to vote
1
Answered by
dyler3 1510 Moderation Voter
9 years ago

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

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 iSvenDerp 233 — 9y
0
Ah, sorry about that. Try it now, and it should work. dyler3 1510 — 9y
0
ok iSvenDerp 233 — 9y
0
Thanks! Accepted and upvoted:) iSvenDerp 233 — 9y
View all comments (2 more)
0
No problem. Glad I could help :P dyler3 1510 — 9y
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. Perci1 4988 — 9y
Ad

Answer this question