local Players = game:GetService('Players')
local Player = Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
game.Workspace[Player.Name.."'sHouse"].DoorWorking.Door.DoorI.ProximityPrompt.ScriptB = true
I am trying to enable a script for 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 And I am wanting to enable a script but I keep getting this error
Players.theking66hayday.PlayerGui.SettingPopup.Frame.TextButton.Script:4: attempt to index nil with ‘Name’
Try declaring the player’s username in a variable before you search the workspace for the house. Example:
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Username = Player.Name
script.Parent.MouseButton1Click:Connect(function()
game.Workspace:WaitForChild(Username .."'sHouse").DoorWorking.Door.DoorI.ProximityPrompt.ScriptB = true
end
I didn’t recommend to use scripts inside Gui’s and Workspace, it is a very bad practice.
I see that your using “Local Player”, it don’t work in Script, only in local scripts.
Also script can’t be enabled/disabled by local script.
local Players = game:GetService('Players')
local Player = Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
local House = workspace:WaitForChild(Player.Name.."'sHouse", 5)
if House then
House.DoorWorking.Door.DoorI.ProximityPrompt.ScriptB.Enabled = true
end
end)
There is a script that makes a ProximityPrompt work. The prompt is located in the user’s house. The code mentioned finds the user’s house, and then enables said script when the user clicks a button.