Hey, Everyone! I have a problem on when I use this script on studio it works but it doesn't when I join a server.
The script is supposed to check if the target player joins the game with a game pass if so it will Tween a GUI away from them, and welcome them to a start screen.
GUI Location: Game.StarterGUI.pAID(ScreenGUI).Frame script location: Workspace.CheckifhasGamepass(Local Script) I have also tried this script with a server script as well...
1 | local id = 987509977 |
2 | game.Players.PlayerAdded:connect( function (player) |
3 | if game:GetService( "GamePassService" ):PlayerHasPass(player, id) then |
4 | local frame = player.PlayerGui:WaitForChild( 'pAID' ).Frame --Assuming script.Parent.Parent was just game.Players.LocalPlayer.PlayerGui |
5 | frame:TweenPosition(UDim 2. new( 0 , 0 , 5 , 0 ), "In" , 'Back' , 10 ) |
6 | end |
7 | end ) |
Replying to a reply quickly would be great, Thanks!
Here's the Local Script
and its Parent
is StarterGui/PlayerGui
01 | local id = 987509977 |
02 | print ( "Preparing Function" ) |
03 | game:GetService( "Players" ).PlayerAdded:Connect( function (player) |
04 | print ( "Using if statment!" ) |
05 | if player and game:GetService( "GamePassService" ):PlayerHasPass(player, id) then |
06 | print ( "Accessing frame" ) |
07 | local frame = player:FindFirstChild( "PlayerGui" ):WaitForChild( 'Paid' ):FindFirstChild( "Frame" ) --Assuming script.Parent.Parent was just game.Players.LocalPlayer.PlayerGui |
08 | print ( "Tweening frame!" ) |
09 | frame:TweenPosition(UDim 2. new( 0 , 0 , 5 , 0 ), "In" , "Back" , 1 , true ) --You Forgot one more argument, plus why make the time argument to 10??? |
10 | print ( "Frame tweened" ) |
11 | else |
12 | print ( "player or game:GetService(" GamePassService "):PlayerHasPass(player, id) is nil/false" ) |
13 | end |
14 | print ( "Player has joined" ) |
15 | end ) |
I used printing
to debug
the code.
A really bad mistake that you have done is that a local script parent
cannot be in game.Workspace
The only parents
that Local Scripts
would function are at StarterGui/PlayerGui, StarterPlayerScripts, StarterCharacterScripts and ReplicatedFirst
Please submit the answer if it worked!