The local script functions perfectly fine when initially joining/spawning.
However, after resetting, the script throws errors, that the Instance is not a valid Member of X, I checked, and the Instance IS actually parented correctly. So I have no Idea why this error is thrown.
Code Snippet Here, Only relevant code
local HUD =Player.PlayerGui:WaitForChild("HUD")
local PlayerCard =HUD:WaitForChild("PlayerCard")
local function updateInfo(Target:Model|Humanoid)
-- Set initial UI values
PlayerCard.PlayerName.Text =Target.Parent.Name
PlayerCard.ID.Text =(TargetPlayer and TargetPlayer.UserId) or "N/A"
end
Mouse.Move:Connect(function()
if Mouse.Target and Mouse.Target.Parent and Mouse.Target.Parent:FindFirstChildWhichIsA("Humanoid") then
updateInfo(Mouse.Target)
end)
Other Details:
- Local script stored in StarterPlayerScripts
- Gui stored in StarterGui
- ResetOnSpawn is Enabled
LMK if more information is needed