Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

ScreenGUI Tweening,Gamepass Script Only works on studio not online?

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...

local id = 987509977
game.Players.PlayerAdded:connect(function(player)
    if game:GetService("GamePassService"):PlayerHasPass(player, id) then 
        local frame = player.PlayerGui:WaitForChild('pAID').Frame --Assuming script.Parent.Parent was just game.Players.LocalPlayer.PlayerGui
        frame:TweenPosition(UDim2.new(0, 0, 5, 0), "In", 'Back', 10)
    end
end)



Replying to a reply quickly would be great, Thanks!

1 comment

0

You need to tween this in a local script, the server cannot do this task.

1 answer

Here's the Local Script and its Parent is StarterGui/PlayerGui

local id = 987509977
print("Preparing Function")
game:GetService("Players").PlayerAdded:Connect(function(player)
    print("Using if statment!")
    if player and game:GetService("GamePassService"):PlayerHasPass(player, id) then 
	print("Accessing frame")       
 local frame = player:FindFirstChild("PlayerGui"):WaitForChild('Paid'):FindFirstChild("Frame") --Assuming script.Parent.Parent was just game.Players.LocalPlayer.PlayerGui
	print("Tweening frame!")
        frame:TweenPosition(UDim2.new(0, 0, 5, 0), "In", "Back", 1, true) --You Forgot one more argument, plus why make the time argument to 10???
	print("Frame tweened")	
  else
		print("player or game:GetService("GamePassService"):PlayerHasPass(player, id) is nil/false")
    end
	print("Player has joined")
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!

2 comments

0

This didn't work. The last Print message was "Preparing Function"

0

So I think the script should be a server script

This discussion is preserved as it was. New answers, comments, and votes are closed.