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

How do I make my admin activate the Cframe?

Asked by
Kitorari 266 Moderation Voter
7 years ago
local A = script.Parent.Blocks.A
local B = script.Parent.Blocks.B
local C = script.Parent.Blocks.C
local D = script.Parent.Blocks.D
local Admins ={"Kitorari"}
local Prefix = "-"

for i,v in pairs(Admins) do
    game.Players:WaitForChild(Admins[i]).Chatted:Connect(function(Msg)
        if Msg:lower() == Prefix .. "Begin" then
            repeat
            A.CFrame = CFrame.new(A.Position + Vector3.new(0.01, 0, 0.01))  
    wait(1)
    until false
        end
    end)
end

I tried using the command -Begin but it doesn't work, What i'm trying to do is move the block to a different position ((No idea what that is yet thus the repeat)) but I'm not sure how.

Any assistance would be welcomed and appreciated ;u;

1 answer

Log in to vote
1
Answered by 7 years ago
Edited 7 years ago

The problem that you are likely facing is that Msg:lower() is always going to be lowercase, but you are comparing it to a string containing an uppercase character. Hence the value

Msg:lower() == Prefix .. "Begin"

will always evaluate to false, and so your command will never be executed. You can fix this by changing "Begin" to "begin".

Also, keep in mind that using WaitForChild in this situation is a bad idea. If at any point you add another player as admin, your current script may wait forever for that player to join the game, thus preventing other admins who may join your game from being able to use the commands. You should use game.Players.PlayerAdded instead to connect players' chat events.

I would also recommend having the Admins table keep track of admins by user ID instead of by username, as players may change their usernames over time.

0
Thank you! Kitorari 266 — 7y
0
However, while the command worked, the cframe didnt Kitorari 266 — 7y
0
And also, how would I do that exactly? Kitorari 266 — 7y
0
Can you be more specific on what aspect of CFrame didn't work? What are you trying to accomplish? MightyBaconOverlord 253 — 7y
Ad

Answer this question