I am trying to make a local variable for my local script in a Gui Button.
I am trying to identify the player's house.
When a player spawns their house in workspace the house model is called (I am using my username as an example):
theking66hayday'sHouse
Here is my local script:
script.Parent.MouseButton1Click:Connect(function(player)
local House = game.Workspace.player.Name.."'sHouse"--keep getting error here
end)
New error Players.theking66hayday.PlayerGui.SettingPopup.Frame.TextButton.Script:4: attempt to index nil with 'Name' This time I am using a normal script in a button ui
local Players = game:GetService('Players')
local Player = Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
local House = workspace:FindFirstChild(Player.Name.."'sHouse")
game.Workspace[Player.Name.."'sHouse"].DoorWorking.Door.DoorI.ProximityPrompt.ScriptB = true

6 comments
I keep getting this error now Players.theking66hayday.PlayerGui.SettingPopup.Frame.TextButton.LocalScript:2: attempt to index nil with 'Name'
Ah, perhaps the "player" argument gives you the name already and no need for the .Name. Anyways, I'm glad you found a solution to your issue!
Sadly it just stopped working the solution I edited my post
What do you mean by a normal script? I believe you can only access the LocalPlayer through a Local Script
Ok, I did already tried through a local script but still same error
Ah, I believe I get it. Perhaps try defining the player inside the function?