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

im trying to make a like lose ingredients and make cake but it doenst seem to work please help me?

Asked by 4 years ago

if game.Players.LocalPlayer.leaderstats.Ingredients.Value > 1 then script.Parent.Activated:Connect(function()

local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)

plr.leaderstats.Ingredients.Value = plr.leaderstats.Ingredients.Value -1
plr.leaderstats.Cake.Value = plr.leaderstats.Cake.Value +1

end) end

2 answers

Log in to vote
0
Answered by
Despayr 505 Moderation Voter
4 years ago

You have everything you need, but you have placed it in the wrong order. If this is a server script, the local player cannot be accessed. So you must use :GetPlayerFromCharacter, like you did later in the script.

script.Parent.Activated:Connect(function()

    local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)

    if plr.leaderstats.Ingredients.Value >1 then
        plr.leaderstats.Ingredients.Value = plr.leaderstats.Ingredients.Value -1
        plr.leaderstats.Cake.Value = plr.leaderstats.Cake.Value +1
    else

    end
end)
0
"script.Parent.Activated" so this is probally a tool(Local Script) Leamir 3138 — 4y
Ad
Log in to vote
-1
Answered by 4 years ago

Is this in a regular script or local script? If it is server script , LocalPlayer cannot be used.

0
Why didn't you posted a comment? Leamir 3138 — 4y

Answer this question