Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to read from a array list?

I am trying to make an array list that checks if the players name is in the game and if so not to affect their camera but I am quite new to arrays and do not really understand how they work. If someone could help me with this that would be great, the lines that are necessary is line 9 and line 26. The code is down below.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DisableCamAll = ReplicatedStorage:WaitForChild("DisableCamAll")
local CamAll = ReplicatedStorage:WaitForChild("CamAll")
local gui = game.ReplicatedStorage["CamOnDev"]
local cam = workspace.CurrentCamera
local CamPart = game.Workspace.CamPart
Disable = true

local playerlist = {"Eletrinn"}

DisableCamAll.OnClientEvent:Connect(function()
	Disable = false
end)

CamAll.OnClientEvent:Connect(function(txt)
	Disable = true
	local FocusPart = game.Workspace:WaitForChild(txt).UpperTorso
	local player = game.Players.LocalPlayer.Name
	print("Cam Enabled.")
	if player == "Eletrinn" then
		game.Players:WaitForChild(player).PlayerGui:WaitForChild("CamOnDev").Frame.Enable.Visible = false
		game.Players:WaitForChild(player).PlayerGui:WaitForChild("CamOnDev").Frame.Disable.Visible = true
	else
		print("You are not Eletrinn")
	end
	if player == playerlist then
		print("Camera Not affected")
	else
		while Disable == true do
			cam.CameraType = Enum.CameraType.Scriptable
			cam:Interpolate(CamPart.CFrame, FocusPart.CFrame, 0.5)
			wait(0.2)
		end
	end
end)

1 answer

✓ Accepted answer

Hey Eletrinn,

You're trying to reference a table in one value so this won't work. You should add a loop that loops through the table like so:

for i,v in ipairs(playerlist) do
	 if player == tostring(v) then
        print("Camera Not affected")
    else
        while Disable == true do
            cam.CameraType = Enum.CameraType.Scriptable
            cam:Interpolate(CamPart.CFrame, FocusPart.CFrame, 0.5)
            wait(0.2)
        end
    end
end

You just need to add that to line 26 and you should be good!

Any help needed? Feel free to contact me

if this helped you mark this as the solution to help others!

Cheers, orcazate

1 comment

0

Thank you for the help, it worked. :)

This discussion is preserved as it was. New answers, comments, and votes are closed.