I am trying to make a script that kick a player and its giving an error

I am trying to make a script that kicks a player and it’s giving an error
output

Argument 1 missing or nil 

Script

local Frame = script.Parent
local Player = script.Parent.Name
local Reason = Frame.Reason

local KickButton = script.Parent.Kick

KickButton.Activated:Connect(function()
	if game.Players:FindFirstChild(Player.Text) then
		game.ReplicatedStorage.KickEvent:FireServer(Player.Text, Reason.Text)
	end
end)

It says the error is in line 8

the variable “Player” looks at the UI’s Name then you try to reference the PROPERTY text from that name

1 Like

Ok, but I was wondering how do I that?

If Name is an object, rename it, Roblox Studio gets confused and thinks you want the property, if not, leave it like that

local Player = script.Parent
2 Likes

Try this script

game.Players.PlayerAdded:Connect(function(Player)
local Frame = script.Parent
local Reason = Frame.Reason

local KickButton = script.Parent.Kick

KickButton.Activated:Connect(function()
	if game.Players:FindFirstChild(Player) then
		game.ReplicatedStorage.KickEvent:FireServer(Player, Reason.Text)
	end
end)
end)