I'm experimenting with Local Parts but I've come across a problem, when I test with Player1 and have that name in permissions it runs both parts of the script even the part after
elseif Player.Name ~= v then
so if I'm in the list It creates both parts, if I'm not it only creates the second part after
elseif Player.Name ~= v then
I don't know why this is, please help me! This is my script:
local bin = game.Workspace:FindFirstChild("LocalBin") Permission = {"Player1","UndiscoveredLimited"} Player = game.Players.LocalPlayer if bin == nil then bin = Instance.new("Camera") bin.Name = "LocalBin" bin.Parent = game.Workspace end for i=1,#Permission do if Player.Name == Permission[i] then part1 = Instance.new("Part",bin) part1.FormFactor = "Custom" part1.Size = Vector3.new(1,2,2) part1.Position = Vector3.new(6,5,5) part1.Anchored = true elseif Player.Name ~= Permission[i] then part1 = Instance.new("Part",bin) part1.FormFactor = "Custom" part1.Size = Vector3.new(1,6,2) part1.Position = Vector3.new(3,10,1) part1.Anchored = true end end
Your issue is that you're looping through every string in "Permission," therefore your script is running twice. Once for Player1, and once for UndiscoveredLimited. When it's running for Player1 and you're logged in as Player1, it runs the first section. When it's running for UndiscoveredLimited and you're logged in as Player1, it runs the second section, because UndiscoverdLimited ~= Player1. Try something like this:
local bin = game.Workspace:FindFirstChild("LocalBin") Permission = {"Player1","UndiscoveredLimited"} Player = game.Players.LocalPlayer if bin == nil then bin = Instance.new("Camera") bin.Name = "LocalBin" bin.Parent = game.Workspace end for i=1,#Permission do if Player.Name == Permission[1] then --first string in 'Permission' part1 = Instance.new("Part",bin) part1.FormFactor = "Custom" part1.Size = Vector3.new(1,2,2) part1.Position = Vector3.new(6,5,5) part1.Anchored = true elseif Player.Name == Permission[2] then --second string in 'Permission' part1 = Instance.new("Part",bin) part1.FormFactor = "Custom" part1.Size = Vector3.new(1,6,2) part1.Position = Vector3.new(3,10,1) part1.Anchored = true end end
If you want to give permission to individual players as it seems you are doing, you might as well just drop the table.
local bin = game.Workspace:FindFirstChild("LocalBin") --nothing here Player = game.Players.LocalPlayer if bin == nil then bin = Instance.new("Camera") bin.Name = "LocalBin" bin.Parent = game.Workspace end for i=1,#Permission do if Player.Name == "Player1" --here part1 = Instance.new("Part",bin) part1.FormFactor = "Custom" part1.Size = Vector3.new(1,2,2) part1.Position = Vector3.new(6,5,5) part1.Anchored = true elseif Player.Name == "Player2" then --and here part1 = Instance.new("Part",bin) part1.FormFactor = "Custom" part1.Size = Vector3.new(1,6,2) part1.Position = Vector3.new(3,10,1) part1.Anchored = true end end