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

else in my if then statement runs as if both conditions are met?

Asked by 5 years ago
Edited 5 years ago

It is hard to explain in the title, but basically when running this

Filter.OnClientEvent:Connect(function(fromfilter)

print("string sent to client after filteration")

if Textbox.Text ~= fromfilter then -- if this condition is met it runs fine

Main.warn.Text = "The name was filtered, pick a new one."

wait(2)

Main.warn.Text = ""

elseif Textbox.Text == fromfilter then -- if this condition is met, it runs a long as if both conditions were met

Main.warn.Text = ""

game.ReplicatedStorage.Buisness_Name.Value = fromfilter

I don't know why they both run if the elseif condition is met but its really annoying me.

Full script:

    local Main = script.Parent

local Textbox = Main.TextBox

local title = Main.title

local line = Main.line

local business = Main.business

local TextService = game:GetService("TextService")

Main.Parent:WaitForChild("Business_Name", 30)

game.Players.LocalPlayer.PlayerGui.Business_Creator.Enabled = false

Filter = game.ReplicatedStorage.Filter

Textbox.Changed:Connect(function()

Textbox.Text = Textbox.Text:sub(0,12)

end)

local uis = game:GetService("UserInputService")

uis.InputBegan:connect(function(key)

if key.KeyCode == Enum.KeyCode.Return then

if Main.Enabled == true then

if Textbox.Text == "" then

Main.warn.Text = "Please enter a name."

wait(1)

Main.warn.Text = ""

else

local tofilter = Textbox.Text

Filter:FireServer(tofilter)

print("string sent to server for filteration")

end

Filter.OnClientEvent:Connect(function(fromfilter)

print("string sent to client after filteration")

if Textbox.Text ~= fromfilter then

Main.warn.Text = "The name was filtered, pick a new one."

wait(2)

Main.warn.Text = ""

elseif Textbox.Text == fromfilter then

Main.warn.Text = ""

game.ReplicatedStorage.Business_Name.Value = fromfilter

Textbox.Text = ""

line:TweenPosition(UDim2.new(0.234, 0,0.091, 0), "Out", "Sine", 1)

title:TweenPosition(UDim2.new(0.295, 0,0.019, 0), "Out", "Sine", 1)

Textbox:TweenPosition(UDim2.new(0.234, 0,9, 0), "Out", "Sine", 5)

title.Text = "ame your business"

wait(0.1)

title.Text = "me your business"

wait(0.1)

title.Text = "e your business"

wait(0.1)

title.Text = " your business"

wait(0.1)

title.Text = "e your business"

wait(0.1)

title.Text = "ze your business"

wait(0.1)

title.Text = "ize your business"

wait(0.1)

title.Text = "mize your business"

wait(0.1)

title.Text = "omize your business"

wait(0.1)

title.Text = "tomize your business"

wait(0.1)

title.Text = "stomize your business"

wait(0.1)

title.Text = "ustomize your business"

wait(0.1)

title.Text = "Customize your business"

business.Text = fromfilter

end

end)

end

end

end)

Filter script:

Filter script: Filter = game.ReplicatedStorage.Filter

Filter.OnServerEvent:Connect(function(player, tofilter)

local Textbox = player.PlayerGui.Buisness_Creator.TextBox

local TextService = game:GetService("TextService")

print(tofilter)

local result = TextService:FilterStringAsync(tofilter, player.UserId)

print(result:GetNonChatStringForBroadcastAsync())



local fromfilter = result:GetNonChatStringForBroadcastAsync()

Filter:FireClient(player, fromfilter)

end)

the game this script is in: https://www.roblox.com/games/3177049393/secret

0
Got anymore code to post? I'd like to try running it myself as I see some "ends" are missing in the sample provided. SimpleFlame 255 — 5y
0
I edited to show the whole script. riceburrito16 40 — 5y

Answer this question