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

I have two scripts with UDim2 animations only the first one works? The second one does not.

Asked by 7 years ago
Edited 7 years ago

My animations does not work in any scripts in RobloxPlayerBeta.exe but in Studio they do.

No errors. ( Local Scripts ) My scripts:

It's only the animations that doesn't work everything else does...

local num = 50
local backbutton = script.Parent.Parent.Back
local Loco = script.Parent.Parent.Loco
local Image = script.Parent.Parent.Island

function onClicked()
    repeat
    local ran_num = math.random()
    until ran_num >= 0.1 and ran_num <= 0.5

    script.Parent:TweenPosition(UDim2.new(0.9, 0, -0.9, 0), "Out", "Quad", 1)
    script.Parent.Parent.TextButton:TweenPosition(UDim2.new(-0.9, 0, 0.9, 0), "Out", "Quad", 1)
    script.Parent.Parent.Change:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), "Out", "Quad", 1)
    Image:TweenPosition(UDim2.new(0.9, 0, 0.4, 0), "Out", "Quad", 1)
    Loco:TweenPosition(UDim2.new(0.42, 0, -0.9, 0), "Out", "Quad", 1)
    wait(.2)
    Loco.Visible = false
    Image.Visible = false
    for i = 1, num do
        backbutton.BackgroundTransparency = 1 - i/num/2
        backbutton.TextTransparency = 1 - i/num/2
        wait()
    end
    if backbutton.BackgroundTransparency == 0.5 then
        for i = 1, num do
            backbutton.BackgroundTransparency = backbutton.BackgroundTransparency - 0.01
            backbutton.TextTransparency = backbutton.TextTransparency - 0.01
            wait()
        end
    end

    script.Parent.Parent.Back.Active = true
    wait(0.6)
end

script.Parent.MouseButton1Down:connect(onClicked)

Works Completely

local i = 0
local label = script.Parent.TextLabel
local button = script.Parent.TextButton
local changebutton = script.Parent.Changelog
local backbutton = script.Parent.Back
local loader = script.Parent.ButtonText

button.Active = false
changebutton.Active = false
backbutton.Active = false

for n = 0, 29 do
    label.Text = "Loading.. ".. i .. "%"
    i = i + 1
    loader.Size = UDim2.new(0, i*2, 0, 50)
    wait(0.0015)
    wait(math.random(0.1,0.5)) -- For now fast. Later a bit slower. when I get save/load slow.
end

for n = 29, 50 do
    label.Text = "Loading.. ".. i .. "%"
    i = i + 1
    loader.Size = UDim2.new(0, i*2, 0, 50)
    wait(0.023)
    wait(math.random(0.2,0.5)) -- For now fast. Later a bit slower. when I get save/load slow.
end

for n = 50, 77 do
    label.Text = "Loading... ".. i .. "%"
    i = i + 1
    loader.Size = UDim2.new(0, i*2, 0, 50)
    wait(0.042)
    wait(math.random(0.4,0.5)) -- For now fast. Later a bit slower. when I get save/load slow.
end

for n = 77, 86 do
    label.Text = "Loading... ".. i .. "%"
    i = i + 1
    loader.Size = UDim2.new(0, i*2, 0, 50)
    wait(0.055)
    wait(math.random(0.4,0.5)) -- For now fast. Later a bit slower. when I get save/load slow.
end

for n = 86, 91 do
    label.Text = "Loading... ".. i .. "%"
    i = i + 1
    loader.Size = UDim2.new(0, i*2, 0, 50)
    wait(0.075)
    wait(math.random(0.4,0.5)) -- For now fast. Later a bit slower. when I get save/load slow.
end

for n = 91, 95 do
    label.Text = "Loading... ".. i .. "%"
    i = i + 1
    loader.Size = UDim2.new(0, i*2, 0, 50)
    wait(0.13)
    wait(math.random(0.42,0.5)) -- For now fast. Later a bit slower. when I get save/load slow.
end

label.Visible = false
button.Visible = true
changebutton.Visible = true
loader.Visible = false
wait(0.1)
button:TweenPosition(UDim2.new(0.5, 0, 0.47, 0), "Out", "Quad", 1)
changebutton:TweenPosition(UDim2.new(0.5, 0, 0.55, 0), "Out", "Quad", 1)
wait(.1)
button.Active = true
changebutton.Active = true

Link to Place: https://www.roblox.com/games/775620657/Island-Tycoon-WIP#!/about

0
If they are in workspace then the problem is that tweening doesn't work from workspace anymore User#13357 0 — 7y
0
It's in StarterGui & there it didn't worked too. MineJulRBX 52 — 7y
0
make sure its a local script and affects only the player seeing it not changing startergui because that doesn't work abnotaddable 920 — 7y
0
But the first script does? And it is local scripts. MineJulRBX 52 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

I played your game, and there are a tonne of errors in the local log. They are saying that those objects don't exist or aren't in that directory or whatever.

You should useWaitForChild() to wait until they are there before they are defined as variables.

local backbutton = script.Parent.Parent:WaitForChild("Back")
local Loco = script.Parent.Parent:WaitForChild("Loco")
local Image = script.Parent.Parent:WaitForChild("Island")

if you get an error saying something along the lines of infinite yield, go onto local server test and look to see if the objects have been removed or moved.

I am sorry if this didn't help you as you didn't provide us with many details, and yes, there are errors.

0
In Studio there isn't any errors by the animation. But I do not use waitforchild so I will definitely try that. MineJulRBX 52 — 7y
Ad

Answer this question