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

I'm not getting any errors, but this script isn't working?

Asked by 9 years ago

I'm kinda new to tweening. For some reason, my script has no errors. But just doesn't work.

Script:

plr = game.Players.LocalPlayer
game.Players.PlayerAdded:connect(function()
    if script.Parent.Position == UDim2.new(-1, 0, 0, 0) then
        script.Parent:TweenPosition(UDim2.new(0, 0, 0, 0))
    end
end)

1 answer

Log in to vote
2
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

Credit to DataStore for pointing out my initial error whilst writing this answer


The PlayerAdded event doesn't work in localscripts! You need to change your code so that this tweens the gui from the server - and index the gui from the player's PlayerGui.


game.Players.PlayerAdded:connect(function(plr)
    plr:WaitForChild('PlayerGui') --Wait for the player's playergui to load
    local gui = plr.PlayerGui.ScreenGui --INDEX THE GUI HERE PLEASE
    --The conditional is kind of redundant. Since the player only joins once
    script.Parent:TweenPosition(UDim2.new(0,0,0,0))
end)
Ad

Answer this question