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

Tweening doesn't work in LocalScript?

Asked by 10 years ago

So I heard that at the moment Tweening only works in LocalScripts. I use Tweening in this script:

local switch="on"
gui=script.Parent.Parent.Frame
function click()
    if switch=="on" then
    gui:TweenPosition(UDim2.new(0, -90, .35, 30), "Out", "Sine", 0.5)
    switch="off"
    script.Parent.Text="Show Info"
    elseif switch=="off" then
    gui:TweenPosition(UDim2.new(0, 0, .35, 30), "Out", "Sine", 0.5)
    switch="on"
    script.Parent.Text="Hide Info"
    end
end
script.Parent.MouseButton1Click:connect(function() click() end)

It is in PlayerGui, works fine in Studio and Solo, but in-game it just doesn't work. Explanation?

Also,

function PlayerAdded(player)
    local screengui = Instance.new('ScreenGui', player.PlayerGui)
    local frame = Instance.new('Frame', screengui)
    local msg = Instance.new('TextLabel', frame)
    local img = Instance.new('ImageLabel', frame)
    frame.Size = UDim2.new(0, 150, 0, 50)
    frame.Position = UDim2.new(0, -150, 0.01, 0)
    msg.Size = UDim2.new(0, 100, 0, 50)
    msg.Position = UDim2.new(0, 50, 0, 0)
    msg.Text = player.Name.." has entered the game! Welcome!"
    msg.BackgroundColor3 = Color3.new(1,1,1)
    msg.TextWrapped = true
    img.Size = UDim2.new(0, 50, 0, 50)
    img.Image = "http://www.roblox.com/thumbs/avatar.ashx?x=352&y=352&format=png&username="..game.Players.LocalPlayer.Name
    frame:TweenPosition(UDim2.new(.5, -75, 0.01, 0), "Out", "Back", 0.5)
    wait(5)
    frame:TweenPosition(UDim2.new(1, 0, 0.01, 0), "In", "Sine", 0.5)
    wait(3)
    screengui:Destroy()
end

for _, player in pairs(game.Players:GetPlayers()) do
    PlayerAdded(player)
end

game.Players.PlayerAdded:connect(PlayerAdded)

This script works fine in Studio in Solo. It obviously doesn't work in-game because it's a script in Workspace. How do I localize this? Thanks in advance.

Answer this question