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

Gamepass GUI Buttons Not Appearing?

Asked by 6 years ago

Basically, I am having trouble with my gamepass run perk. The user buys it in game, they reset and boom the GUI should appear. So you'd think, but it doesn't. It works in Studio, but when the person who owns the gamepass leaves and re-joins the game, the GUI doesn't appear, same goes for when they reset. I'll post my script so hopefully one of you good fellow Roblox'ers can help.

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        if game.MarketplaceService:PlayerOwnsAsset(player,996728468) then
            character.Humanoid.WalkSpeed = 75
            game.Players.LocalPlayer.PlayerGui.NoticeGUI.Note.Visible = true
            game.Players.LocalPlayer.PlayerGui.ScreenGui.Run.Visible = true
            game.Players.LocalPlayer.PlayerGui.ScreenGui.Walk.Visible = true
            game.Players.LocalPlayer.PlayerGui.ScreenGui.TextButton.Visible = false
        end
    end)
end)

Thanks for your time and I hope you can help me out.

1 answer

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

You need to use PlayerHasPass instead of PlayerOwnsAsset. But keep in mind PlayerHasPass is server side only, so it should not go in a localscript.

local id = 103728213 --id here

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:Connect(function(character)
    if game:GetService("GamePassService"):PlayerHasPass(player, id) then 
character.Humanoid.WalkSpeed = 75
player.PlayerGui:WaitForChild("NoticeGUI").Note.Visible = true
player.PlayerGui:WaitForChild("ScreenGui").Run.Visible = true
player.PlayerGui:WaitForChild("ScreenGui").Walk.Visible = true
player.PlayerGui:WaitForChild("ScreenGui").TextButton.Visible = false
    else
        --Do whatever here
    end
end)
end)

Wiki page. Hopefully this worked for you, if it did please accept my answer! Thanks!

0
Thanks, I'm still stuck as it's saying NoticeGUI is not a valid member of PlayerGui. I've no idea why it isn't moving to the Players GUI but I really need to know how. N30_Vehicle -2 — 6y
0
Try using WaitForChild. PyccknnXakep 1225 — 6y
0
Sorry, I'm a newbie to scripting. What line would I add this to? Thanks. N30_Vehicle -2 — 6y
0
I'll edit my answer for you. PyccknnXakep 1225 — 6y
View all comments (24 more)
0
Done. PyccknnXakep 1225 — 6y
0
Thanks. It still won't appear and it says in the console "Infinite yield possible on 'Players.N30_Vehicle.PlayerGui:WaitForChild("NoticeGui")' N30_Vehicle -2 — 6y
0
Then maybe the NoticeGui isn't cloning and/or is misspelled. PyccknnXakep 1225 — 6y
0
Where is the NoticeGui anyway? PyccknnXakep 1225 — 6y
0
It's all spelled correctly. I really have no idea how else to tackle this issue but it seems like it might be a Roblox problem since you've tried everything. N30_Vehicle -2 — 6y
0
Where is it located? PyccknnXakep 1225 — 6y
0
It's in StarterGui. N30_Vehicle -2 — 6y
0
Is it called NoticeGUI or NoticeGui? PyccknnXakep 1225 — 6y
0
NoticeGUI. N30_Vehicle -2 — 6y
0
Just did some research, replace WaitForChild with FindFirstChild. That should work for you. PyccknnXakep 1225 — 6y
0
I'm clueless. I really do appreciate your help, don't know why this still isn't working. Just says "Attempt to index a nil value" N30_Vehicle -2 — 6y
0
Me too. But if my answer at least helped you please accept it, it would mean alot. PyccknnXakep 1225 — 6y
0
Does it depend on where the script is? I put it into ServerScriptService. N30_Vehicle -2 — 6y
0
Also, I don't seem to have an accept answer button? What does it look like because there's nothing but an upvote system. N30_Vehicle -2 — 6y
0
Oh. You need to put the script in the workspace. The accept answer button would be on the top right of my answer. PyccknnXakep 1225 — 6y
0
ServerScriptService can't access GUIs. PyccknnXakep 1225 — 6y
0
I don't seem to have an answer button. I turned off Ad Block to see if I could find it but it's still not there? Strange. N30_Vehicle -2 — 6y
0
Oh, I'm sorry. It's located at the bottom of my answer, right here: https://gyazo.com/da46502d4328b3520ea4d26ee4275caf PyccknnXakep 1225 — 6y
0
I only have the Report icon which baffles me. I just signed up today so do I need to wait 24 hours before I can accept answers? N30_Vehicle -2 — 6y
0
Yeah, that might be the problem. Just remember to accept since it'll help my reputation and yours :) PyccknnXakep 1225 — 6y
0
I will definitely remember. You really have helped me a lot trying to get this to work, thank you very much for your time and contribution. N30_Vehicle -2 — 6y
0
LOL, I got it. FilteringEnabled is on which is what interferes with my script. I'm so so so so sorry to ask but do you know how to get around it without turning it off? N30_Vehicle -2 — 6y
0
I wouldn't recommend turning FilteringEnalbed off, as it will ruin your game. You might want to research on how FE is good. PyccknnXakep 1225 — 6y
0
I understand now. I just want to know how do I get my script to adapt to working with FilteringEnabled on? N30_Vehicle -2 — 6y
Ad

Answer this question