How to make a fly script

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! :slight_smile:

3 Likes

Not to your question but to the script first: exploiter can just run the ban RemoteEvent and ban everyone on the server. This is a huge security risk. Besides, there is now a much easier method with the textchatservice:

besides, everyone can write ban…
but to your question:
How To Make A Character Fly - Scripting Support - Developer Forum | Roblox

Dont use the UI part, only the main part
Have a nice day

5 Likes

Thank you for your reply! I decided, though, not to do the fly script, as I would much rather use ForeverHD’s admin for what I’m working on. Have a nice day! :slight_smile:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.