wait(15)
local DIDend = {game.Workspace.DEndPart, game.Workspace.SEndPart, game.Workspace.TEndPart, game.Workspace.Neon1EndPart, game.Workspace.DessertEndPart,
game.Workspace.ASHEndPart, game.Workspace.BHEndPart, game.Workspace.WOEndPart, game.Workspace.DISDEndPart, game.Workspace.OREndPart, game.Workspace.CodingEnd}
local Players = game:GetService("Players")
local PlayerName = game.StarterGui.PlayerWin.Frame.PlayerName
local PlayerWinValue = game.ReplicatedStorage.EventsAndValues.PlayerWinValue
local PlayerWins = game.ReplicatedStorage.EventsAndValues.PlayerWinsValue
local Debounce = false
local Position = game.Workspace.Goto.Position
function teleport()
local target = CFrame.new(Position)
for i, player in ipairs(game.Players:GetChildren()) do
if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
player.Character.HumanoidRootPart.CFrame = target + Vector3.new(i, i * 5, i)
end
end
end
for _,v in pairs(DIDend) do
v.Touched:Connect(function(hit)
if not Debounce then
Debounce = true
local player = Players:GetPlayerFromCharacter(hit.Parent)
PlayerWins.Value = player.leaderstats.Wins.Value
PlayerWinValue.Value = hit.Parent.Name
local userId = player.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size180x180
for i,v in pairs (game.Players:GetPlayers()) do
local imageLabel = v.PlayerGui.PlayerWin.Frame.PlayerAV
imageLabel.Image = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
imageLabel.Size = UDim2.new(0, 180, 0, 180)
game.ReplicatedStorage.EventsAndValues.ShowGui:FireAllClients(game.Players:GetPlayerFromCharacter(hit.Parent))
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player.leaderstats.Wins.Value = player.leaderstats.Wins.Value + 1
player.leaderstats.Bits.Value = player.leaderstats.Bits.Value + 25
wait(5)
teleport()
end
wait(20)
Debounce = false
end
end)
end
It works like 60% of the time, it works until it stops working 1 time and then it just breaks for the rest of the game, basically, this is a winner GUI that pops up when someone ones, I sometimes get a userID nil error or the hit. Parent. The name doesn't print out leaving the text field as "Label" I need help making this script work each time seeing its the last major bug in my game.

2 comments
Sometimes you hit with a part that is not part of the Character, you should check if player is not nil.
That might do it Thanks.