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

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

Asked by 3 years ago

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 
0
The BackgroundTransparency appears as 0.01, not 0. Ziffixture 6913 — 3y
0
So I would check if it was equal to 0.01? JeffTheEpicRobloxian 258 — 3y
0
That cant be right, its meant to loop until it reaches to 0 JeffTheEpicRobloxian 258 — 3y
0
Do yyou think i should remove the conditional instead? JeffTheEpicRobloxian 258 — 3y
View all comments (2 more)
0
Try removing the end on line 27 maybe that works MediaHQ 53 — 3y
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. PhantomVisual 992 — 3y

1 answer

Log in to vote
1
Answered by
TGazza 1336 Moderation Voter
3 years ago

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!

Ad

Answer this question