Hey i wrote a script but i keep getting this error (attempt to index nil with ‘SecondsUsed’) and i’m wondering how to fix it. i know the error and know a way to fix it but i’m a bit to lazy for that and i know for a fact that there is a easier way. local Count = 0
script.Parent.Parent.CheckPlayerTouched.OnClientEvent:Connect(function()
while script.Parent.Parent.Parent.Parent.BoolVal.Value == true do
wait(1)
Count = Count + 1
script.Parent.Text = "Time: "…Count
end
end)
script.Parent.Parent.PlayerFinished.OnClientEvent:Connect(function()
local Player = game.Players.LocalPlayer
Player.SecondsUsed.Value = Count
game.Workspace.StopTimer.StopTimer:FireServer()
end)
I suppose it is in a local script (as OnClientEvent should be listened to on the client), so the problem is that you don’t have a Player variable. Use game.Players.LocalPlayer to get the player from the client, or edit the script that fires the remote event to pass the Player variable