Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

attempt to index global 'player' (a nil value) help?

so i tried to make a tool but i got this error. 11:31:42.972 - Players.Abacus300.Backpack.Cash Giver.LocalScript:2: attempt to index global 'player' (a nil value) This is my code

local module = require(script.Parent:WaitForChild("ModuleScript") )local mouse = (player:GetMouse() )local player = game.Players.LocalPlayer() script.Parent.Activated:Connect(function() module.Lift() end)

Please Help me

1 answer

Next time please use the code block when posting code, and don't have it all jumbled up. Space it out, it'll help.

The problem (as you might imagine) is right here:

local player = game.Players.LocalPlayer()

.LocalPlayer() is not a function or anything where you would need the (), so just remove it.

Correct code:

local player = game.Players.LocalPlayer

Let me know if you have any questions

This discussion is preserved as it was. New answers, comments, and votes are closed.