I'm trying to make a ban button and it shows me this error, can anyone help me?
Here's my script
local banDataStore = game:GetService("DataStoreService"):GetDataStore("banDataStore") local Frame = script.Parent.Parent script.Parent.MouseButton1Click:Connect(function() local Player = Frame.Username.Text local PlayerUID = Player.UserId local success, errorMessage = pcall(function() banDataStore:SetAsync(PlayerUID, true) end) if not success then print("L") end Player:Kick("You've been banned from this game!") end)
I assume that the Frame.Username is a TextBox, which would probably be causing the error.
You can't get the content of a TextBox in a server script, so you'd have to use RemoteEvents.
You are doing Player = Frame.Username.Text which is a string value, if you'd like to get the actual player you'd do
local Player = game.Players[Frame.Username.Text]
and it should work