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:

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

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.


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

Answer this question