I made a script to ban players, when you press ban on a gui it is supposed to kick you from the game but it doesn't, why not?
-- UI Variables
local frame = game.StarterGui:WaitForChild("BanPanel"):WaitForChild("Frame")
local nameBox = frame.Name
local reasonBox = frame.Reason
local banButton = frame.Ban
local timeBox = frame.Time
-- Ban player function
function banPlayer()
local playerToBan = game.Players:FindFirstChild(nameBox.Text)
-- Epoch time to unban
local convertedTime = tonumber(timeBox.Text)
local numTime = convertedTime * 86400
local unbanTime = os.time() + numTime
print(unbanTime)
-- Create a banned tag
local banTag = Instance.new("BoolValue")
banTag.Name = "Banned"
banTag.Parent = playerToBan
-- Kick player
playerToBan:Kick("You are banned for"..timeBox.Text.." days:"..reasonBox.Text.." is not aloud in Silencer.")
print(playerToBan.Name.." has been banned from the game")
return unbanTime
end
-- Click to ban
local returnedBanTime
banButton.MouseButton1Click:Connect(function()
returnedBanTime = banPlayer()
end)
I think it might be kind of obvious what this is supposed to do but when I click the ban button it does nothing

1 comment
Is this a server or client script? Also, you are referencing the GUI in StarterGui, not PlayerGui.