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 4 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


01local Player = game.Players.LocalPlayer
02local PlayerGUI = Player.PlayerGui
03local StartMenu = PlayerGUI:WaitForChild("StartMenu")
04local Text = StartMenu:WaitForChild("Text")
05local ModulePlayerNms
06local PromptStartMenu = game.ReplicatedStorage.PromptStartMenu
07 
08PromptStartMenu.OnClientEvent:Connect(function(Table)
09    ModulePlayerNms = Table
10end)
11function CheckPlayerPerm(PlayerToCheck, ModuleToSearch)
12    local IfPlayer
13    for _, plr in pairs(ModuleToSearch) do
14        if PlayerToCheck.Name == plr then
15            IfPlayer = PlayerToCheck
View all 52 lines...

Area that doesn't run


01local TextString = "Thank You For Using J-Commands! This Is Still In BETA Phase So Except Some Bugs..."
02local IfAdminText = "Welcome, "..Player.Name.." You Have Permission To Use Commands!"
03if Text.BackgroundTransparency == 0 then -----------NEVER SEEMS TO RUN?!
04    for i = 1, #TextString do
05        Text.Text = string.sub(TextString, 1, i)
06        wait(.07)
07    end
08    wait(2)
09    if CheckPlayerPerm(Player, ModulePlayerNms) then
10        for i = 1, #IfAdminText do
11            Text.Text = string.sub(IfAdminText, 1, i)
12            wait(.07)
13        end
14    end
15end
0
The BackgroundTransparency appears as 0.01, not 0. Ziffixture 6913 — 4y
0
So I would check if it was equal to 0.01? JeffTheEpicRobloxian 258 — 4y
0
That cant be right, its meant to loop until it reaches to 0 JeffTheEpicRobloxian 258 — 4y
0
Do yyou think i should remove the conditional instead? JeffTheEpicRobloxian 258 — 4y
View all comments (2 more)
0
Try removing the end on line 27 maybe that works MediaHQ 53 — 4y
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 — 4y

1 answer

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

i would re-write the section :

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

As

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

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

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

to

1for Transparency =  1, 0, -.01 do
2    Text.BackgroundTransparency = Transparency
3    wait(.001)
4end
5Text.BackgroundTransparency  = 0 -- make sure the BackgroundTransparency  is at 0 not 0.01 or something!
6--// 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