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

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

Asked by 6 years ago

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!

0
You need to tween this in a local script, the server cannot do this task. User#5423 17 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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!

0
This didn't work. The last Print message was "Preparing Function" Alanisme124 0 — 6y
0
So I think the script should be a server script saSlol2436 716 — 6y
Ad

Answer this question