Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

"Attempt to index nil with Stats"=?

Asked by
Qariter 110
4 years ago

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'

01local pressed = false
02 
03script.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
09                    print("pressed.")
10                pressed = true
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()
View all 41 lines...
1
On line 11 the player is found from "script.Parent" maybe that's your error. Player1_Joined 271 — 4y
0
Oof! i see now.. Thank you! I wish i could give you a upvote. Qariter 110 — 4y

Answer this question