Hello, I'm making a data store changer for a speedrun game. I already have the data store set up, and I'm working on the data store updater. Here is my code:
local Players = game:GetService("Players")
local pausetime = script.Parent
local time = script.Parent.Parent:FindFirstChild("SpeedunTimerGUI")
local function onPauseButtonTouch(touchpart)
local partParent = touchpart.Parent
local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
if humanoid then
local player = Players:GetPlayerFromCharacter(partParent)
local leaderstats = player.leaderstats
local pb = leaderstats and leaderstats:FindFirstChild("Best Time")
if pb then
if leaderstats.BestTime > time then
leaderstats.BestTime.Value = time
end
end
end
end
pausetime.Touched:Connect(onPauseButtonTouch())
I get the error on line 7 telling me "Workspace.Speedrun Timer.Timer_Pause.Script:7: attempt to index nil with 'Parent'". What is the problem with referencing the parent?

1 comment
Tysm!