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

time position help?

Asked by
NotSoNorm 777 Moderation Voter
9 years ago

Ok so idk, this is a local script, and I'm tryign to make it work with filtering enabled, but it doesn't work with it on or without it on what am I doing wrong?

local Audio = script.Parent.Parent.Sound
local playerpath = game.Players.LocalPlayer.PlayerGui:WaitForChild("Timer") or game.Players.LocalPlayer.PlayerGui:FindFirstChild("Timer")

Audio.Changed:connect(function()
local Length = Audio.TimeLength
repeat wait() until Length ~= 0
    for i = 0, math.ceil(Length), 1 do
        local PitchLevel = Audio.Pitch
        local Difference = PitchLevel - 1 
        wait(1 - Difference)
            if Audio.IsPlaying then
                local TimePos = math.ceil(Audio.TimePosition)

                --script.Parent.Parent.TextBar.Text = TimePos
                playerpath.MainTiming.Empty.Filler:TweenSize(UDim2.new(0, TimePos, 1, 0), "Out", "Bounce", 1, true)
            else 
            if not Audio.IsPlaying then
                wait(1)
                --script.Parent.Parent.TextBar.Text = "0" 
                wait(.2)
                playerpath.MainTiming.Empty.Filler:TweenSize(UDim2.new(0, 0, 1, 0), "Out", "Bounce", 1, true)
                break
            end
        end
    end
end)
0
output? HungryJaffer 1246 — 9y
0
none NotSoNorm 777 — 9y
0
Could you include the functionality of the script in your question please. magiccube3 115 — 9y

1 answer

Log in to vote
0
Answered by
Marios2 360 Moderation Voter
9 years ago

LocalPlayer, you're calling it before it exists...

...That's all, really. All you need is

repeat wait() until game.Players.LocalPlayer

on the top or any other line that would wait for LocalPlayer to appear.

As for the script in general, of course it works in FilteringEnabled as the script only refers to the Player as an instance and it's children ever (Along with Audio which i suppose is in an allowed position too). You were too concentrated to that though so you thought it had more restrictions than it had. Or you didn't know that scripts execute when possible, which is usually a bit before the first Player instance gets created. So you must wait for said Player instance to exist before working with it.

repeat wait() until game.Players.LocalPlayer

local Audio = script.Parent.Parent.Sound
local playerpath = game.Players.LocalPlayer.PlayerGui:WaitForChild("Timer") or game.Players.LocalPlayer.PlayerGui:FindFirstChild("Timer")

Audio.Changed:connect(function()
local Length = Audio.TimeLength
repeat wait() until Length ~= 0
    for i = 0, math.ceil(Length), 1 do
        local PitchLevel = Audio.Pitch
        local Difference = PitchLevel - 1 
        wait(1 - Difference)
            if Audio.IsPlaying then
                local TimePos = math.ceil(Audio.TimePosition)

                --script.Parent.Parent.TextBar.Text = TimePos
                playerpath.MainTiming.Empty.Filler:TweenSize(UDim2.new(0, TimePos, 1, 0), "Out", "Bounce", 1, true)
            else 
            if not Audio.IsPlaying then
                wait(1)
                --script.Parent.Parent.TextBar.Text = "0" 
                wait(.2)
                playerpath.MainTiming.Empty.Filler:TweenSize(UDim2.new(0, 0, 1, 0), "Out", "Bounce", 1, true)
                break
            end
        end
    end
end)

Hope i helped!

0
Instead of "repeat wait() until game.Players.LocalPlayer" couldn't you just do " game.Players:WaitForChild("LocalPlayer") " Validark 1580 — 9y
0
Yes, yes you could. But they do the same thing in all. Marios2 360 — 9y
Ad

Answer this question