Hey developers!
While scripting an admin panel I ran into this issue.
When I click the “kick” button, it should kick the player I put in. But that’s not happening. Please help!
LocalScript:
--Variables--
local button = script.Parent
local input = script.Parent.Parent.UserInput
local event = game.ReplicatedStorage.Kick
--Script--
button.MouseButton1Click:Connect(function()
local result = event:InvokeServer(input.Text)
print(result)
if result == "Success." then
button.Visible = false
end
end)
Script:
--Variables--
local admins = {
["iamajust"] = 1;
}
local event = game.ReplicatedStorage.Kick
--Script--
event.OnServerInvoke:Connect(function(player, victim)
if admins[player.Name] then
if game.Players:FindFirstChild(victim) then
game.Players:FindFirstChild(victim):Kick([[
You have been kicked.
-Kiba Admin
]])
return "Success."
else
return "Fail."
end
end
end)
I would really appreciate it if someone could help me!
Have a nice day, iamajust
event.OnServerInvoke = function(player, victim)
if admins[player.Name] then
if game.Players:FindFirstChild(victim) then
game.Players:FindFirstChild(victim):Kick([[
You have been kicked.
-Kiba Admin
]])
return "Success."
else
return "Fail."
end
end
end
--Variables--
local button = script.Parent
local input = script.Parent.Parent.UserInput
local event = game.ReplicatedStorage.Kick
--Script--
button.MouseButton1Click:Connect(function()
local result = event:FireServer(input.Text)
print(result)
if result == "Success." then
button.Visible = false
end
end)
--Variables--
local admins = {
["iamajust"] = 1;
}
local event = game.ReplicatedStorage.Kick
--Script--
function isInTable(tableValue, toFind)
local found = false
for _,v in pairs(tableValue) do
if v == toFind then
found = true
break
end
end
return found
end
event.OnServerInvoke:Connect(function(player, victim)
if isInTable(admins, player.Name) then
if game.Players:FindFirstChild(victim) then
game.Players:FindFirstChild(victim):Kick([[
You have been kicked.
-Kiba Admin
]])
return "Success."
else
return "Fail."
end
end
end)
I just wanted to explain @heII_ish’s code. Your current code is treating a RemoteFunction like an Event. RemoteEvents will use events but RemoteFunctions use Callbacks. They are write-only members of certain objects that take a function.