Why is 'player' returning nil?

Viewed 43

It keeps returning nil for player and saying that im trying to index a nil with 'WaitForChild' even though I have tried adding a wait command and changing player to 'game.Players.LocalPlayer' I'm new to scripting and I don't know what else to do.

local buyButton = script.Parent
local player = game:GetService("Players").LocalPlayer
local multiplier = player:WaitForChild("Multiplier")

buyButton.MouseButton1Up:Connect(function()
    if multiplier.Value == 0 then
        multiplier.Value = 1
    end
end)
1 Answers

Instead of local player = game:GetService("Players").LocalPlayer you want to do:

   local players = game:GetService("Players")
   local player = players.localplayer
Related