Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My admin panel's kick command is not working. What did I do wrong?

Asked by 2 years ago

I was making a kick command for my admin panel and it didn't work. I did not even get an error.

The local script:

local kickEvent = game.ReplicatedStorage.Commands.Kick -- this is for the kick
local target = script.Parent.Player -- this is the target
local reason = script.Parent.Reason -- the reason for a kick, and, ban
local player = game.Players.LocalPlayer -- this is the player on the admin panel
local panel = script.Parent --This is for the admin panel

panel.Kick.MouseButton1Click:Connect(function()
    kickEvent:FireServer(player, target, reason)
end)

This is the event script:

local commands = game.ReplicatedStorage.Commands
local playerService = game.Players

commands.Kick.OnServerEvent:Connect(function(player, reason, target)
    playerService.target.Text:Kick(reason.Text)
end)

commands.GlobalBan.OnServerEvent:Connect(function()

end)

commands.ServerBan.OnServerEvent:Connect(function()

end)

commands.GiveModItem.OnServerEvent:Connect(function()

end)

2 answers

Log in to vote
0
Answered by 2 years ago

In the event script, you tried to find an instance called 'target' in players.

Instead of doing that, you can use FindFirstChild, that way you can find the target.

commands.Kick.OnServerEvent:Connect(function(player, reason, target)
    playerService:FindFirstChild(target).Text:Kick(reason.Text)
end)
0
your code is wrong plus this is not efficient, you dont need to sent the instance as an argument, you can just send the text sata5pa3da 286 — 2y
0
also, im pretty sure the text is local so you cant access it from the server sata5pa3da 286 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

you dont need to send in the instance, you can just send the text of the text objects. so your local script might look like this:

local kickEvent = game.ReplicatedStorage.Commands.Kick -- this is for the kick
local target = script.Parent.Player.Text -- this is the target
local reason = script.Parent.Reason.Text -- the reason for a kick, and, ban
--local player = game.Players.LocalPlayer -- this is the player on the admin panel
local panel = script.Parent --This is for the admin panel

panel.Kick.MouseButton1Click:Connect(function()
    kickEvent:FireServer(target, reason)
end)

And your server script might look like this:

local commands = game.ReplicatedStorage.Commands
local playerService = game.Players

commands.Kick.OnServerEvent:Connect(function(player, target, reason)

local player_to_kick = playerService:FindFirstChild(target)


if player_to_kick then
player_to_kick:Kick(reason)

end

end)

commands.GlobalBan.OnServerEvent:Connect(function()

end)

commands.ServerBan.OnServerEvent:Connect(function()

end)

commands.GiveModItem.OnServerEvent:Connect(function()

end)

Hope I helped!

Answer this question