Hello! I am currently trying to make a custom admin panel for one of my games, in which I would like a fly command. For example, you type “;fly” into the chat, and you are lifted off the ground and into the air. I’ve tried a few ways of doing this, but none of them worked.
Here is my code:
--Variables
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local BanEvent = game.ReplicatedStorage:WaitForChild("BanEvent") --Ignore this lol
--Functions
Player.Chatted:Connect(function(message, Player)
if message == "!ban" then
BanEvent:FireServer(message, Player)
elseif message == ";fly" then
game.Workspace.Gravity = 0
Humanoid.RigType = Enum.HumanoidRigType.R6
if message == ";unfly" then
game.Workspace.Gravity = 196.2
Humanoid.RigType = Enum.HumanoidRigType.R15
end
end
end)
What is the best way to do about doing this? Thank you all for your help and have a wonderful day!