Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- you will need to have a screen gui with just a text label in it, then place it inside your script and drag your script into ServerScriptService
- local function onPlayerChatted(player, message)
- local adminName = "Admin" -- Replace with the actual admin's name
- local prefix = ":warn" -- The command prefix
- if message:sub(1, #prefix) == prefix then
- local command = string.sub(message, #prefix + 1)
- local targetPlayer, reason = command:match("(%S+)%s+(.+)")
- if targetPlayer and reason then
- local target = game.Players:FindFirstChild(targetPlayer)
- if target then
- local warningCount = target:FindFirstChild("WarningCount") or Instance.new("IntValue")
- warningCount.Name = "WarningCount"
- warningCount.Parent = target
- warningCount.Value = warningCount.Value + 1
- if warningCount.Value == 3 then
- target:Kick("You have been kicked after 3 warnings. The reason for being kicked is " .. reason .. ". If you wish to rejoin, please stop doing what you were doing.")
- else
- local warningMessage = adminName .. " has warned you for " .. reason .. ". Please stop or you will get kicked."
- local warningScreenGui = Instance.new("ScreenGui")
- local warningTextLabel = Instance.new("TextLabel")
- warningScreenGui.Name = "WarningScreenGui"
- warningScreenGui.Parent = target.PlayerGui
- warningTextLabel.Name = "WarningTextLabel"
- warningTextLabel.Parent = warningScreenGui
- warningTextLabel.BackgroundColor3 = Color3.new(1, 0, 0)
- warningTextLabel.Size = UDim2.new(0, 400, 0, 200)
- warningTextLabel.Position = UDim2.new(0.5, -200, 0.5, -100)
- warningTextLabel.Font = Enum.Font.SourceSansBold
- warningTextLabel.Text = warningMessage
- warningTextLabel.TextColor3 = Color3.new(1, 1, 1)
- warningTextLabel.TextScaled = true
- warningTextLabel.TextWrapped = true
- wait(5) -- Display the warning for 5 seconds
- warningScreenGui:Destroy()
- end
- end
- end
- end
- end
- game.Players.PlayerAdded:Connect(function(player)
- player.Chatted:Connect(function(message)
- onPlayerChatted(player, message)
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement