Anyone know why I'm getting this error? I'm trying to run a script from a local script, here's my code.

LocalScript:

local replicatedstorage = game:GetService("ReplicatedStorage")
local KickPlayar = replicatedstorage:WaitForChild("KickPlayerCommand")

local function kickdaplayer()
	KickPlayar:FireServer()
end

while true do
	if not game.Workspace.yas:FindFirstChild("KillA") then
		KickPlayar:FireServer()
	end
	wait(0.1)
end

Script:

local replicatedstorage = game:GetService("ReplicatedStorage")
local kickdaplayerevent = Instance.new("RemoteEvent", replicatedstorage)
kickdaplayerevent.Name = "KickPlayerCommand"

local function timetokick()
	local player = game.Players:GetChildren()
	player:Kick("Nah.")
end

kickdaplayerevent.OnServerEvent:Connect(timetokick)

Error:

Workspace.RunKickEvent:7: attempt to call a nil value

The error is on the script, not the local script. Anyone know what the problem is?

2 comments

0

Your "player" variable refers to an array of every player in-game:P. The Kick method is only callable on an individual Player Instance.

0

OK, thanks.