Help with storing a players usernames

I have a script that’s a timer-ish I have a way to store a username in a string, but when I try to get it again I cant, any help?
image
This is storing the name


And I cant seem to get it back

Here is the whole script,

local cd = false
script.Parent.ClickDetector.MouseClick:Connect(function(player)
	if cd == false then
		cd = true
		local char = workspace:WaitForChild(player.Name)
		script.Parent.plrname.Value = char.Name  -- store username here
		script.Parent.Value.Value = 200
		char.HumanoidRootPart.CFrame = CFrame.new(909.51, 7.877, -246.11)
		wait(1)
		local timelimit = script.Parent.Value
		while timelimit.Value >= 1 do
			wait(0.5)
			timelimit.Value = timelimit.Value - 1 
		end
		if timelimit.Value == 0 or 1 then
			workspace:WaitForChild(script.Parent.plrname.Value):FindFirstChild("Humanoid").Health = 0 -- error getting the username here
			cd = false

		end
		
		
	end
end)

Is the object you are storing the player’s name inside a Stringvalue?

Yes its inside a stringvalue named “plrname”
image

do you need in other scripts or just this script?
if you want it in this script only why not use a local variable instead?

I only need it in this script, I never thought about using a local variable though.

you can add an empty variable before the click detector event and give it the player’s name when needed

 local player
local cd = false
local timerStart = 200
script.Parent.ClickDetector.MouseClick:Connect(function(player)
	if cd then return end
	cd = true
	local char = player.Character or player.CharacterAdded:Wait()
	local humanoid = char:FindFirstChild("Humanoid")
	local root = char:FindFirstChild("HumanoidRootPart")
	if not humanoid or not root or not char then cd = false return end
	root.CFrame = CFrame.new(909.51, 7.877, -246.11)
	wait(1)
	local timer = timerStart
	while timer >= 1 do
		wait(0.5)
		timer -= 1
	end
	humanoid:TakeDamage(100)
	cd = false
end)

You have the player instance inside the lambda function connected to the click detector’s MouseClick RBXScriptSignal object, you can get that player’s name by indexing its “Name” property, i.e;

print(player.Name)