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

Was there an API change to TweenPosition lately?

Asked by 7 years ago

I've been having an issue with TweenPosition lately. I can't figure out the problem on why it will not work correctly anymore. It works in a 2 player test server in Studio but not online. This issue came up yesterday. This script is not a local script. Game has FE enabled.

Was it an API change maybe?

  • This is for a surfaceGUI

Script:

local P = script.Parent
local lights = P.Parent.Lights:GetChildren()
local enabled = true

local slider = P.Mount.GUI.BG.Body.SliderBG.Slider
local title = P.Mount.GUI.BG.Header.Content
title.Text = script.Subject.Value..": OFF"
local event = script.SwitchEvent

function Enable()
    enabled = true
    slider:TweenPosition(UDim2.new(0.5, 0, 0, 0), "Out", "Quart", 0.5, true)
    wait(0.25)
    title.Text = script.Subject.Value..": ON"
    title.TextColor3 = Color3.new(0,0.5,0)
    workspace.EnergyManager.Variables.Usage.Value = workspace.EnergyManager.Variables.Usage.Value + 200 
    slider.BackgroundColor3 = Color3.new(0,0.5,0)
    for i = 1, #lights do
        lights[i].Lamp.Light.Enabled = true
        wait(0.1)
    end 
end

function Disable()
    enabled = false
    slider:TweenPosition(UDim2.new(0, 0, 0, 0), "Out", "Quart", 0.5, true)
    wait(0.25)
    title.Text = script.Subject.Value..": OFF"
    workspace.EnergyManager.Variables.Usage.Value = workspace.EnergyManager.Variables.Usage.Value - 200 
    title.TextColor3 = Color3.new(0.5,0,0)
    slider.BackgroundColor3 = Color3.new(0.5,0,0)
    for i = 1, #lights do
        lights[i].Lamp.Light.Enabled = false
    end
end

function PowerCheck()
    local power = _G.IsPowerOn()
    if (power) then
        slider.Parent.Visible = true
        if (enabled) then
            title.Text = script.Subject.Value..": ON"
            title.TextColor3 = Color3.new(0,0.5,0)
            slider.BackgroundColor3 = Color3.new(0,0.5,0)
        else
            title.Text = script.Subject.Value..": OFF"
            title.TextColor3 = Color3.new(0.5,0,0)
            slider.BackgroundColor3 = Color3.new(0.5,0,0)
        end
    else
        title.Text = "No power"
        title.TextColor3 = Color3.new(0.5,0,0)
        slider.Parent.Visible = false
        if (enabled) then
            Disable()
        end
    end
end

event.OnServerEvent:connect(function()
    P.Mount.Sound:Play()
    if (enabled) then
        Disable()
    else
        Enable()
    end
end)

-- Post init and main loop
Disable()

while not pcall(function()_G.IsPowerOn() end) do wait() end

while wait(0.5) do
    PowerCheck()
end

Any reason why it could not working anymore? It was working as of 2 days ago.

0
Maybe try a local script, I tried to tween a Gui with a script but didn't work then I tried it in a LocalScript and It worked in the real game in the the studio! Hydrogyn 155 — 7y

1 answer

Log in to vote
1
Answered by 7 years ago

If FilteringEnabled is enabled, you should always use LocalScripts when dealing with GUIs and client-related things. Tamper with LocalScripts and your code to get it to work.

Because this issue isn't something wrong with your code, I see no reason to re-post it and not change it. If you have any questions regarding how to update your code, though, post it in the comments on this reply.

0
In Studio, by the way, you can almost consider all scripts to be treated as a LocalScript, which explains why some things work in Studio but not online. joritochip 705 — 7y
0
Even if FE is false you should still handle GUIs on the client, using LocalScripts. OldPalHappy 1477 — 7y
0
Yep! ^ joritochip 705 — 7y
Ad

Answer this question