"Attempt to index nil with Stats"=?
I was attempting to make a button that gives someone a certain value, but it seems to break on lines 20,21,24. Could anyone help?
Error: Attempt to index nil with 'Stats'
03 | script.Parent.Touched:Connect( function (part) |
04 | if part.Parent:FindFirstChild( "Humanoid" ) then |
05 | print ( "found hmanoid" ) |
06 | if not part.Parent:FindFirstChild( "GotReward" ) then |
07 | print ( "hasn't got reward" ) |
08 | if game.Players:GetPlayerFromCharacter(part.Parent) and pressed = = false then |
11 | local player = game.Players:GetPlayerFromCharacter(script.Parent) |
12 | local gotreward = Instance.new( "BoolValue" ) |
13 | gotreward.Name = "GotReward" |
14 | gotreward.Parent = part.Parent |
15 | script.Parent.press:Play() |
16 | script.Parent.Transparency = 1 |
17 | script.Parent.SpringConstraint.Visible = false |
18 | script.Parent.Parent.Pressed.Transparency = 0 |
19 | script.Parent.Parent.Pressed.SpringConstraint.Visible = true |
20 | print (player.Stats:FindFirstChild( "OwnsSummerNoob" ).Value) |
21 | if player.Stats:FindFirstChild( "OwnsSummerNoob" ).Value = = 0 then |
24 | player.Stats:FindFirstChild( "OwnsSummerNoob" ).Value = player.Stats:FindFirstChild( "OwnsSummerNoob" ).Value + 1 |
25 | game.ReplicatedStorage.SendRewardMessage:FireClient(player, "You've unlocked: Summer Noob" ) |
28 | game.ReplicatedStorage.SendWarn:FireClient(player, "You already have Summer Noob, so you'll get 500 points instead." ) |
29 | player.Stats.Points.Value = player.Stats.Points.Value + 500 |
31 | game.Workspace.SummerEventButtonPressed.Value = true |
33 | script.Parent.Transparency = 0 |
34 | script.Parent.SpringConstraint.Visible = true |
35 | script.Parent.Parent.Pressed.Transparency = 1 |
36 | script.Parent.Parent.Pressed.SpringConstraint.Visible = false |