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

How do I make my admin activate the Cframe?

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

✓ Accepted answer

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.

4 comments

0

Thank you!

0

However, while the command worked, the cframe didnt

0

And also, how would I do that exactly?

0

Can you be more specific on what aspect of CFrame didn't work? What are you trying to accomplish?

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