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

the word "player" is underlined blue, Why?

Asked by 4 years ago
Edited 4 years ago

the word "player" is underlined blue and i have no idea why??

local z = script.parent
local x = z.Part
local y = z.Leaves1
local hits = 0
local hitsN = 5
    x.touched:connect(function(hit)
        if hit.Parent.Name == "Axe" then
        **player**= game.Players:GetPlayerFromCharacter(hit.Parent.Parent)
            hits = hits + 1
            if hits == hitsN then
                hits = 0
                x.Anchored = false
                y.Anchored = false
                y.CanCollide = false   
                wait(0.01)
                hit:Destroy()
                x.Rotation = Vector3.new(45,0,0)
                player.leaderstats.Lumber.Value = player.leaderstats.Lumber.Value  + 15

            end
        end
    end)

thanks, TSSRafa

1 answer

Log in to vote
0
Answered by
pwx 1581 Moderation Voter
4 years ago

I'm not entirely sure why you are putting stars around the variable, but anyway it's better to change the variable to local since it's already within' a function and hasn't been specified anywhere else. Like so:

local player = game:GetService('Players'):GetPlayerFromCharacter(hit.Parent.Parent)
0
There is probably stars in the OP around the identifier to show where is the issue. But that was the only line causing "trouble" so I don't know why he pasted other code which just added noise programmerHere 371 — 4y
Ad

Answer this question