So, I made this ban GUI script but when I run it, it says in the output that the player does not exist.
Here's the local script in the GUI.
local Username = script.Parent.Parent.Username.TextBox.Text
local Reason = script.Parent.Parent.Reason.TextBox.Text
local Evidence = script.Parent.Parent.Evidence.TextBox.Text
script.Parent.MouseButton1Click:Connect(function()
print("Button was pressed!")
if game.Players:FindFirstChild(Username) then
print("Succesfully got a player!")
game.ReplicatedStorage.ModEvents.BanPlayer:FireServer(Username, Reason)
else
print("Player does not exist!")
end
end)
Here's the output when I press it:
And here's the server script that gets the remote event:
game.ReplicatedStorage.ModEvents.BanPlayer.OnServerEvent:Connect(function(player, Username, Reason)
game.Players:FindFirstChild(Username):Kick("\nYou have been banned for:\n"..Reason.."\n By: "..player.Name.. " | "..player.UserId)
game.Players:FindFirstChild(Username).modstats.Banned.Value = true
if game.Players:FindFirstChild(Username).modstats.Banned.Value == true then
game.Players:FindFirstChild(Username):Kick("\nYou are for:\n"..Reason.."\n By: "..player.Name.. " | "..player.UserId)
end
end)
Can someone help?
