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

Tiny bit of halp with for loop plz? (Apologies, don't know what else to say 4 title)

Asked by 6 years ago

So uhh

I haz a localscript

And I haz a loading screen that I is trying to haz

And I haz sum variables here

local LocalPlayer = game:GetService("Players").LocalPlayer
local LoaderGui = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("LoadingScreen")
local Frame = LoaderGui.Frame or LoaderGui:WaitForChild("Frame")
local Text = Frame.TextLabel or Frame:WaitForChild("TextLabel")
LoaderGui.Enabled = true
LocalPlayer.Character.Humanoid.WalkSpeed = 0
LocalPlayer.Character.Humanoid.JumpPower = 0
wait()
local character = LocalPlayer.Character
local humroot = character.HumanoidRootPart

And I haz a for loop

for i=0,1,0.025 do
    Frame.BackgroundTransparency = i
    Text.TextTransparency = i
    Text.TextStrokeTransparency = (i * 0.5) -- I want haz this to be fixe! :P
    wait(0.025)
end

And I want the TextStrokeTransparency to start off at 0.5 and go at half speed of the rest of the stuff without putting it into a different loop.

Full script here in case u need haz infomation

-- In a LocalScript, in a FilteringEnabled game, in StarterCharacterScripts
local LocalPlayer = game:GetService("Players").LocalPlayer
local LoaderGui = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("LoadingScreen")
local Frame = LoaderGui.Frame or LoaderGui:WaitForChild("Frame")
local Text = Frame.TextLabel or Frame:WaitForChild("TextLabel")
LoaderGui.Enabled = true
LocalPlayer.Character.Humanoid.WalkSpeed = 0
LocalPlayer.Character.Humanoid.JumpPower = 0
wait()
local character = LocalPlayer.Character
local humroot = character.HumanoidRootPart
local platform = Instance.new("Part", game.Workspace)
-- set up properties of the platform
platform.Transparency = 0.7
platform.Material = "Glass"
platform.Size = Vector3.new(5, 1, 5)
platform.Anchored = true
platform.CustomPhysicalProperties = PhysicalProperties.new(5, 2, 0.5, 5, 0.5)
platform.Parent = game.Workspace
platform.Size = Vector3.new(5, 1, 5); platform.Material = "Glass"; platform.Anchored = true; platform.Transparency = 0.4
platform.Name = "Platform"
local positionCo = coroutine.create(function()
    while true do
        platform.Position = Vector3.new(humroot.Position.X, -0.501, humroot.Position.Z)
        game:GetService("RunService").RenderStepped:Wait()
    end
end)
coroutine.resume(positionCo)
wait(0.1)
Text.Text = "Loading done!"
wait(1)
for i=0,1,0.025 do
    Frame.BackgroundTransparency = i
    Text.TextTransparency = i
    Text.TextStrokeTransparency = (i * 0.5)
    wait(0.025)
end
character.Humanoid.WalkSpeed = game:GetService("StarterPlayer").StarterHumanoid.WalkSpeed
character.Humanoid.JumpPower = game:GetService("StarterPlayer").StarterHumanoid.JumpPower
LoaderGui.Enabled = false
--[[ Commented out because ROBLOX Player hates this code, probz because not in ServerScriptService
--setting the thingies--
do
    local PhysicsService = game:GetService("PhysicsService")
    local plfGroup = "platformGroup"
    local plyGroup = "playerGroup"
    PhysicsService:CreateCollisionGroup(plfGroup)
    PhysicsService:CreateCollisionGroup(plyGroup)
    PhysicsService:SetPartCollisionGroup(platform, plfGroup)
        for _, part in pairs(character:GetChildren()) do
            if part:IsA("BasePart") then
                PhysicsService:SetPartCollisionGroup(part, plyGroup)
            end
        end
    PhysicsService:CollisionGroupSetCollidable(plfGroup, "Default", false)
    PhysicsService:CollisionGroupSetCollidable(plyGroup, plfGroup, true)
end
-- done setting the thingies --
--]]

(Please note, all typos here are intentional and intended to be humorous

also note: u can help me make the physicsservice thing work 2 if u want, but idc if u do or not)

2 answers

Log in to vote
0
Answered by 6 years ago

Hi! I'm BlackOrange

Ok, so one way to NOT have making another loop is simply throwing in a if statement. Check when i = 0.5 or higher, since your going up by 0.25 or 0.025 (I forgot), It definitely will hit 0.5 eventually. So:

for i=0,1,0.025 do
    wait(0.025)
    Frame.BackgroundTransparency = i
    Text.TextTransparency = i
    if i == 0.5 then
        Text.TextStrokeTransparency = (i * 0.5) -- I want haz this to be fixe! :P
    end
end

BUT WAIT! Can we make this better? Yes! By using > / <

for i=0,1,0.025 do
    wait(0.025)
    Frame.BackgroundTransparency = i
    Text.TextTransparency = i
    if i >= 0.5 then
        Text.TextStrokeTransparency = (i * 0.5) -- I want haz this to be fixe! :P
    end
end

NANI?! It now only increases TextStrokeTransparency, simple fix! Copy paste what you had... and...

for i=0,1,0.025 do
    wait(0.025)
    Frame.BackgroundTransparency = i
    Text.TextTransparency = i
    if i >= 0.5 then
        Text.TextStrokeTransparency = (i * 0.5) -- I want haz this to be fixe! :P
        Frame.BackgroundTransparency = i
        Text.TextTransparency = i
    end
end

I'm not gonna do what you said about halfspeed because I don't get what you mean xD.

So! Hopefully this gave you an idea!

Best of luck!

BlackOrange3343

0
By half speed I meant like, start at the same moment as the rest of the stuff, but go at 0.0125 instead of 0.025. If not possible, your stuff will work too. sweetkid01 176 — 6y
Ad
Log in to vote
0
Answered by
RjsMc 48
6 years ago

Ok so you want the TextStrokeTransparency to go away too, but just half its size. Here is the thing!

When you multiply a number by 0.5, for example, let i = 0,1,0.025 (Basically your script).

Now the i will only be half transparent due to the fact your multiplying it by 0.5. You are dividing the final (1) by 2. So the text is only transparent by 0.5. There is somewhat an easy fix for beginner scripters which is listed below.

Im gonna try to help. Here is what I came up with: (Read comments to know whats goin on)

for i=0,1,0.025 do
    Frame.BackgroundTransparency = i
    Text.TextTransparency = i
    wait(0.025)
end
-- Then just make another for loop.
for i=0,2,0.025 do
    Text.TextStrokeTransparency = (i * 0.5)
    wait(0.025)
end

The reason why there are 2 for loops is because the first loop will go by super easily. That way the next for loop will start almost instantly after. Here is the thing, for = i 0,2,0.25. Notice how its 2 now. This is because once you multiply the i by 0.5, your basically dividing, making 1, actually 0.5.

0
Mine is designed for low scripters. However this also works. RjsMc 48 — 6y

Answer this question