Script is broken! Could anyone help?

This script has been bugging me for hours. Could somebody help, it’s suppose to check the player but it just says "ServerScriptService.ServerScript:109: attempt to index nil with ‘Character’"

			local part = game.Workspace.Yes:FindFirstChild("Part")
			part.Touched:Connect(function(hit)
				local Player = game.Players:GetPlayerFromCharacter(hit)
				staus.Value = Player.Character.Name.." Has Won the round!"
				Player.leaderstats.Wins.Value += 1

Could somebody help me?

1 Like

Change local Player = game.Players:GetPlayerFromCharacter(hit) to local Player = game.Players:GetPlayerFromCharacter(hit.Parent)

EDIT: I didn’t actually read your script correctly, sorry. But the reason why it’s attempting to index nil with character is that your character probably hasn’t loaded yet, try using Player.CharacterAdded:Wait(). Could help.

Worked likes a charm! Thanks alot.

Ah, no problem, hope it helps!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.