Attempt to index nill with "Name"

Hi, I’m trying to make a system, where when a player stays at a cash register for a specific amount of time, and then unclaims the register automatically.

I’m getting the error, that player is “nill”.

I’ve looked up so many solutions none of them seemed to work.

Main Code:

local Claimed = script.Parent.Claimed
local LoggedPlayer = script.Parent.LoggedPlayer
local PassingTime = script.Parent.PassingTime
local Events = game.ReplicatedStorage.Registers




Events.Register1.Event:Connect(function(player)
	if Claimed.Value == true and player.Name == LoggedPlayer.Value and player.PlayerHasClaimedRegister.Value == true and PassingTime.Value == script.Parent.MaxTime.Value then
		Claimed.Value = false
		script.Parent.MaxTime.Value = 1200
		PassingTime.Value = 0
		script.Parent.Display.TimePassed.Text = 0
		player.PlayerHasClaimedRegister.Value = false
		script.Parent.Display.UIGradient.Color = ColorSequence.new(Color3.new(0.686275, 1, 0.713725), Color3.new(1, 1, 1))
		LoggedPlayer.Value = ""    
		script.Parent.Display.TextLabel.Text = "Unclaimed Register (Click to Claim)"
		end
end)

Any help would be gladly appreciated.

are you using a remote event or a blindable event?

Can you maybe send the script where you :Fire() the event?

I’m using a blindable event, since I’m doing it from a server script.

Okay, here:

local Claimed = script.Parent.Claimed
local PassingTime = script.Parent.PassingTime
local Events = game.ReplicatedStorage.Registers

		if script.Parent.MaxTime.Value == PassingTime.Value then
			wait(1)
			Events.Register1:Fire()
		end

This is part of the main script, but it’s where it fires the event.

You have forgot to pass in the player instance
Events.Register1:Fire(player)

2 Likes

Oh, okay. Let me try that. Thanks!

Thanks so much! It worked just fine! :heart:

You’re welcome my dude! I’m happy if I can help.
:slight_smile:

1 Like