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
Hey there, could you try doing this instead?
script.Parent.MouseButton1Click:Connect(function(player) local House = game.Workspace[player.Name .. "'sHouse"] end)
I suggest printing out the result to really know what's going on.
local Players = game:GetService('Players') local Player = Players.LocalPlayer script.Parent.mouseButton1Click:Connect(function() local House = workspace:FindFirstChild(Player.Name.."'s House") if House then -- do stuff here end end)
Found answer can't disable scripts in local script also I finally solved the player issue too