Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Table not working as i want it to?

Asked by
Paldi 109
7 years ago
Edited 7 years ago

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)
0
You really should tab your code correctly BlueTaslem 18071 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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.

Ad

Answer this question