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?
This is storing the name
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)
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;