local commands = {}
local admins = {
"MAD_DENISDAILY2";
"poopfartbarf1130";
"Mickeyrus1";
"andrust51";
}
local prefix = "/"
local function findPlayer(name)
for _, player in pairs(game.Players:GetPlayers()) do
if string.lower(player.Name) == name then
return player
end
end
return nil
end
local function isAdmin(player)
for _, v in pairs(admins) do
if v == player.Name then
return true
end
end
return false
end
commands.tp = function (sender, arguments)
print("TP Function fired by "..sender.Name)
for _, playerName in pairs(arguments) do
print(playerName)
end
local playerToTeleportName = arguments[1]
local playerToTeleportName = arguments[2]
if playerToTeleportName and playerToTeleportName then
local plrToTP = findPlayer(playerToTeleportName)
local plrToTPto = findPlayer(playerToTeleportName)
if plrToTP and plrToTPto then
plrToTP.Character.HumanoidRootPart.CFrame = plrToTPto.Character.HumanoidRootPart.CFrame
print("Successfully moved!")
end
end
end
commands.speed = function(sender, arguments)
print("Speed command fired by "..sender.Name)
local playerToGiveSpeedTo = arguments[1]
local amountOfSpeedToGive = arguments[2]
if playerToGiveSpeedTo then
local plr = findPlayer(playerToGiveSpeedTo)
if plr then
plr.Character.Humanoid.WalkSpeed = tonumber(amountOfSpeedToGive)
print(playerToGiveSpeedTo.." was given Walkspeed "..amountOfSpeedToGive)
end
end
end
commands.kill = function(sender, arguments)
print("Kill command fired by "..sender.Name)
local playerToKill = arguments[1]
if playerToKill then
local plr = findPlayer(playerToKill)
if plr then
plr.Character.Humanoid.Health = 0
print(playerToKill.." was killed by "..sender.Name)
end
end
end
commands.health = function(sender, arguments)
print("Health command was fired by "..sender.Name)
local playerToGiveHealthTo = arguments[1]
local amountOfHealthToGive = arguments[2]
if playerToGiveHealthTo then
local plr = findPlayer(playerToGiveHealthTo)
if plr then
plr.Character.Humanoid.MaxHealth = tonumber(amountOfHealthToGive)
plr.Character.Humanoid.Health = tonumber(amountOfHealthToGive)
print(playerToGiveHealthTo.." was given "..amountOfHealthToGive)
end
end
end
commands.name = function(sender, arguments)
print("Name command was fired by "..sender.Name)
local playerToName = arguments[1]
local nameToGive = arguments[2]
if playerToName then
local plr = findPlayer(playerToName)
if plr then
local character = plr.Character
local Humanoid = character:WaitForChild("Humanoid")
Humanoid.DisplayName = nameToGive
end
end
end
commands.fling = function(sender, arguments)
print(“Fling command was fired by “..sender.Name)
local playerToFling = arguments[1]
if playerToFling then
local plr = findPlayer(playerToFling)
if plr then
-- Then I have no idea
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message,recipient)
if isAdmin(player) then
message = string.lower(message)
local splitString = message:split(" ")
local slashCommand = splitString[1]
local cmd = slashCommand:split(prefix)
local cmdName = cmd[2]
if commands[cmdName] then
local arguments = {}
for i = 2, #splitString, 1 do
table.insert(arguments,splitString[i])
end
commands[cmdName](player,arguments)
end
end
end)
end)
✓ ANSWER ACCEPTED
How would I make a fling command?
1 answer
✓ Accepted answer
Well, not entirely. Assuming that is in a server script, Player.LocalPlayer would be a nil value, as it can only be referenced from LocalScripts. Additionally, I would use :FindFirstChild() instead of :WaitForChild, as FindFirstChild would return nil if HRP does not exist, while :WaitForChild would return an infinite yield possible warning.
script.Parent.Touched:Connect(function(touch)
if touch.Parent:FindFirstChild("HumanoidRootPart") == nil then return end --Make sure HRP exists
local HRP = touch.Parent:FindFirstChild("HumanoidRootPart") -- HumanoidRootPart
local Humanoid = touch.Parent:FindFirstChild("Humanoid") -- Humanoid
Humanoid.Sit = true -- Makes the player sit
local BodyVelocity = Instance.new("BodyVelocity", HRP) -- Creates a new BodyVelocity force inside HRP
BodyVelocity.Velocity = Vector3.new(0,200,0) -- Sets velocity, you can change this up depending on what direction you want the player to go to in.
wait(1)
BodyVelocity:Destroy() -- Deletes the force, making the player start to come back down.
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
This is on touch not by saying something but I still can modify it