RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"create a command chat system with 4 random commands, add comments to code"
-- server script for command chat system local commands = {"dance", "spin", "jump", "wave"} -- list of commands local prefix = "!" -- prefix for commands game.Players.PlayerAdded:Connect(function(player) player.Chatted:Connect(function(message) if string.sub(message, 1, 1) == prefix then -- check if message starts with prefix local command = string.sub(message, 2) -- get command without prefix for _, cmd in pairs(commands) do if cmd == command then -- check if command is valid -- do something based on command if cmd == "dance" then player.Character.Humanoid:LoadAnimation(game:GetService("InsertService"):LoadAsset(123456):GetChildren()[1]):Play() elseif cmd == "spin" then player.Character.HumanoidRootPart.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.Angles(0, math.rad(360), 0) elseif cmd == "jump" then player.Character.Humanoid.Jump = true elseif cmd == "wave" then player.Character.Humanoid:LoadAnimation(game:GetService("InsertService"):LoadAsset(987654):GetChildren()[1]):Play() end end end end end) end)