I have a GUI, which purpose is to simply kick players, and a kick reason is included. The GUI also includes the names of in-game players on a list so I dont need to type out the player name in a text button.
The script will run perfectly in studio, will not error in-game, but still dosent work, can anyone help?
Normal Script in Screen GUI(Called RemoteFunctions):
local remote = script.Parent["Kicking Function"]
remote.OnServerInvoke = function(var) -- WHEN INVOKE RUN SCRIPT
local players = game.Players:GetPlayers()
for i = 1,#players do
if var == players[i] then return var end
end
end
Local Script in Screen GUI(Called Invoke[needed?]):
wait()
script.Parent.Script.RemoteFunction:InvokeServer()
Normal Script in GUI button(called Kicking script):
local remote = script.Parent.Parent.Parent["Kicking Function"]
script.TakeInfo.OnInvoke = function(var,Reason)
local player = game.Players:GetChildren()
for i,v in ipairs(player) do
if var == v then
v:Kick("You have been kicked for Reason: "..Reason)
end
end
end
Local script in GUI button(Called ListPlayers):
player = game.Players.LocalPlayer
Kick = script.Parent
Kick.MouseButton1Down:connect(function()
local people = game.Players:GetChildren()
for i,people in ipairs(people) do
local newLine = Instance.new("TextButton", script.Parent.Parent)
newLine.Text = people.Name
newLine.Name = people.Character.Name
newLine.BackgroundColor3 = script.Parent.BackgroundColor3
newLine.TextColor3 = script.Parent.TextColor3
newLine.Size = UDim2.new(0, 150,0, 50)
newLine.Position = script.Parent.Position - UDim2.new(0,0,-i,-i)
newLine.TextXAlignment = Enum.TextXAlignment.Center
newLine.TextYAlignment = Enum.TextYAlignment.Center
newLine.FontSize = Enum.FontSize.Size18
newLine.Font = Enum.Font.SourceSans
newLine.MouseButton1Down:connect(function()
local ID = newLine.Name
local KickReason = script.Parent.Parent.KickReason
local Reason = script.Parent.Parent.KickReason.Text
local verify = script.Parent.Parent.Parent["Kicking Function"]:InvokeServer(ID)
if KickReason.Text == "Kick Reason" or KickReason.Text == "" then
KickReason.BackgroundColor3 = Color3.new(255,0,0)
wait(1)
KickReason.BackgroundColor3 = newLine.BackgroundColor3
else
local Kick = script.Parent["Kicking script"].TakeInfo:Invoke(verify,Reason)
end
end)
end
end)
