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

Table not working as i want it to?

How can i make the "If" statement look if the "text.Text" is ANY of the "words" and not look if its not ONE of them like it does right now? (i really don't know how to explain this another way xD sorry)

wait(1)
local player = game.Players.LocalPlayer
local name = game.ReplicatedStorage.Players:FindFirstChild(player.Name).CivilName
local cam = workspace.CurrentCamera
local text = script.Parent.NameText
local storage = game.ReplicatedStorage.Players:FindFirstChild(player.Name)
local words = {"Type in your civil name!",""," ", "  "}
function Done()
for i,v in ipairs(words) do
if text.Text ~= v then
	    name.Value = text.Text
		player.Backpack.Camera:Destroy()
		local room = workspace.Rooms:GetChildren()
	        local AllNone,DidFind=true,false
	        for i,v in pairs(room) do
	                if v.Player.Value == player.Name and not DidFind then
	                        local pos = v.Dummy.Torso
	                        DidFind=true
							cam.CameraSubject = pos
								    cam.CoordinateFrame = CFrame.new(pos.Position)  
	                           * CFrame.Angles(0, 0, 0)
	                           * CFrame.new(0, 0.5, 8)       
	                elseif not DidFind then
	                        AllNone=false
	                end
			end

--GUI

script.Parent.Visible = false
script.Parent.Parent.Super.Visible = true
script.Parent:Destroy()
else
	text.BackgroundColor3 = Color3.fromRGB(220,0,0)
	wait(.1)
	text.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
	wait(.1)
	text.BackgroundColor3 = Color3.fromRGB(220,0,0)
	wait(.1)
	text.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
	wait(.1)
	text.BackgroundColor3 = Color3.fromRGB(220,0,0)
	wait(.1)
	text.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
	wait(.1)
end
end
end
script.Parent.Done.MouseButton1Click:connect(Done)

1 comment

0

You really should tab your code correctly

1 answer

If you make the if statement "if text.Text == v" the script will go through every value in your table. If the value (say word[1]) is equal to the text it will run the if statement. However if word[1] is not the text it will skip it and go to word[2]. If no values in your table is equal to the text the if statement will not run at all. Correct me if I misunderstood your question.

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