Script looking for a player with a nil value as a name

SO as the title suggests, my script is looking for a player that has a nil value as their name…
I don’t know how or why it’s doing it.

local playername = script.Value.Value
local DragDetector = script.Parent.DragDetector

DragDetector.DragStart:Connect(function(plr)
	script.Value.Value = plr.Name

	local box = DragDetector.Parent
	
	
	
	if script.Value.Value == plr.Name then

		local player = game:GetService("Players"):WaitForChild(playername)
		local pay = player:WaitForChild("PayAmount")
		print(pay.Parent.Name)
		
		
		box:GetPropertyChangedSignal("Parent"):Connect(function()
			if box.Parent == game.Workspace.ReadyToDestroy then
				pay.Value = pay.Value + 1
				box:Destroy()
			end
		end)
	end
end)

according to my script it should be looking for a player with the name held by the value

and according to the warning i get

  22:46:26.629  Infinite yield possible on 'Players:WaitForChild("")'  -  Studio
  22:46:26.629  Stack Begin  -  Studio
  22:46:26.629  Script 'Workspace.Boxes.Box.Script', Line 13  -  Studio - Script:13

I don’t know why it thinks the value is an empty name as during playtest after grabbing the box, the value is set to my username…
same goes for serverside too, the value is my username

i need help
I can provide a .rbxl if needed

(my mom can’t pick me up even though im scared, please help me /j)

You’ve only set the value of playername once, at the very start of the script. I would suggest adjusting the value of the variable within the DragStart event!

1 Like

I have found my issue…
on line 13, the variable “playername” is looking for script.Value.Value
and that is different from getting the value from a value…
now i know my issue (after crying for almost an hour)
DON’T MAKE THE SAME MISTAKE AS ME PLEASE, LOOK FOR YOUR VALUES AS “variable.value” rather than putting “Value.Value” in the variable T^T

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.