Recently, I have been working on a Gui. I am trying to make it so when someone clicks it, it runs a require script. The thing is i need it to detect who clicked the button. Here is my code:

function parentPressed()
	local player = game.Players.LocalPlayer
require(4702368120).load(player.Name)
end
script.Parent.MouseButton1Down:connect(parentPressed)

It always sais: Players.LurkingEntlty.PlayerGui.test.scrollMain.Musical Drone.Loader:3: attempt to index nil with 'Name'

3 comments

0

local player only works in local scripts

0

To get around local player you can pass the player to the function and do game.players:FindFirstChild(player)

0

Do you mean like this? function parentPressed() local player = game.Players.LocalPlayer game.Players:FindFirstChild(player) require(4702368120).load(player.Name) end script.Parent.MouseButton1Down:connect(parentPressed) beacuase it didnt work