Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Attempt To Call A Nil Value?

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)

2 comments

0

What line is the error at?

0

Line 19

2 answers

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.

2 comments

0

The problem is that I don't know how to

2

Then search it up

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

5 comments

0

Now it says " is not a valid member of Players" without the username

0

Well I assume the text is the players name right?

0

Yes, it is

0

Is it capitalised correctly?

0

Yes, It is

This discussion is preserved as it was. New answers, comments, and votes are closed.