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

i am trying to add + 15 "Lumber" But the the words "player" are underlined blue, Why??

Asked by 4 years ago

why is this underlined blue?

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
        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

0
is this a script inside a tool? Azure_Kite 885 — 4y
0
no its inside the Tree Object User#31501 0 — 4y
0
And ill assume "axe" is a tool Azure_Kite 885 — 4y
0
yes User#31501 0 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

you gotta make a refference to the player

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)
0
the first word player is now underlined blue User#31501 0 — 4y
0
its fine, just write 'local' before it like what u did with your other variables Azure_Kite 885 — 4y
0
Tysm User#31501 0 — 4y
Ad

Answer this question