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

How Come A Section Of My Code Never Runs In My Local Script?

I'm making a Greeting Gui to go with my chat commands and things aren't going to well. It seems that ROBLOX Studio isn't running a section of my code, the part where the text is set and the check on the player's permission is done. An reason why?


Code


local Player = game.Players.LocalPlayer
local PlayerGUI = Player.PlayerGui
local StartMenu = PlayerGUI:WaitForChild("StartMenu")
local Text = StartMenu:WaitForChild("Text")
local ModulePlayerNms 
local PromptStartMenu = game.ReplicatedStorage.PromptStartMenu

PromptStartMenu.OnClientEvent:Connect(function(Table)
	ModulePlayerNms = Table
end)
function CheckPlayerPerm(PlayerToCheck, ModuleToSearch)
	local IfPlayer
	for _, plr in pairs(ModuleToSearch) do
		if PlayerToCheck.Name == plr then
			IfPlayer = PlayerToCheck
		end
		if IfPlayer ~= nil then
			return true
		else
			return false
		end
	end
end
for Transparency =  1, 0, -.01 do
	Text.BackgroundTransparency = Transparency
	wait(.001)
end
local TextString = "Thank You For Using J-Commands! This Is Still In BETA Phase So Except Some Bugs..."
local IfAdminText = "Welcome, "..Player.Name.." You Have Permission To Use Commands!"
if Text.BackgroundTransparency == 0 then -----------NEVER SEEMS TO RUN?!
	for i = 1, #TextString do
		Text.Text = string.sub(TextString, 1, i)
		wait(.07)
	end
	wait(2)
	if CheckPlayerPerm(Player, ModulePlayerNms) then
		for i = 1, #IfAdminText do
			Text.Text = string.sub(IfAdminText, 1, i)
			wait(.07)
		end
	end
end 
----SKIPS TO HERE 
wait(2)
for Transparency = 0, 1, .01 do
	Text.BackgroundTransparency = Transparency
	Text.TextTransparency = Transparency
	wait(.001)
end
wait(3)
StartMenu:Destroy()
print("Done!")

Area that doesn't run


local TextString = "Thank You For Using J-Commands! This Is Still In BETA Phase So Except Some Bugs..."
local IfAdminText = "Welcome, "..Player.Name.." You Have Permission To Use Commands!"
if Text.BackgroundTransparency == 0 then -----------NEVER SEEMS TO RUN?!
	for i = 1, #TextString do
		Text.Text = string.sub(TextString, 1, i)
		wait(.07)
	end
	wait(2)
	if CheckPlayerPerm(Player, ModulePlayerNms) then
		for i = 1, #IfAdminText do
			Text.Text = string.sub(IfAdminText, 1, i)
			wait(.07)
		end
	end
end 

6 comments

0

The BackgroundTransparency appears as 0.01, not 0.

0

So I would check if it was equal to 0.01?

0

That cant be right, its meant to loop until it reaches to 0

0

Do yyou think i should remove the conditional instead?

0

Try removing the end on line 27 maybe that works

0

The condition checking of BackgroundTrasparency seems redundant as you previously ran a loop that guarenteed it to be 0. I would just remove that if statement altogether.

1 answer

✓ Accepted answer

i would re-write the section :

local TextString = "Thank You For Using J-Commands! This Is Still In BETA Phase So Except Some Bugs..."
local IfAdminText = "Welcome, "..Player.Name.." You Have Permission To Use Commands!"
if Text.BackgroundTransparency == 0 then -----------NEVER SEEMS TO RUN?!
    for i = 1, #TextString do
        Text.Text = string.sub(TextString, 1, i)
        wait(.07)
    end
    wait(2)
    if CheckPlayerPerm(Player, ModulePlayerNms) then
        for i = 1, #IfAdminText do
            Text.Text = string.sub(IfAdminText, 1, i)
            wait(.07)
        end
    end
end 

As

local TextString = "Thank You For Using J-Commands! This Is Still In BETA Phase So Except Some Bugs..."
local IfAdminText = "Welcome, "..Player.Name.." You Have Permission To Use Commands!"
if math.floor(Text.BackgroundTransparency+0.5) == 0 then -----------
    for i = 1, #TextString do
        Text.Text = string.sub(TextString, 1, i)
        wait(.07)
    end
    wait(2)
    if CheckPlayerPerm(Player, ModulePlayerNms) then
        for i = 1, #IfAdminText do
            Text.Text = string.sub(IfAdminText, 1, i)
            wait(.07)
        end
    end
end 

Since the code you're dealing with 0.0n numbers and that for loop doesn't get to 0 so you would have to round the number to the nearest int

Or change your for loop:

From

for Transparency =  1, 0, -.01 do
    Text.BackgroundTransparency = Transparency
    wait(.001)
end

to

for Transparency =  1, 0, -.01 do
    Text.BackgroundTransparency = Transparency
    wait(.001)
end
Text.BackgroundTransparency  = 0 -- make sure the BackgroundTransparency  is at 0 not 0.01 or something!
--// little hacky i know lol but its a way to make sure the transparency is at 0 so the following if statement works!


Hope this helps!

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