-
What do you want to achieve?
I have a Gamepass door script And multiple people Told me once buying the Gamepass, The door does not Go away. -
What is the issue?
I do not know whats wrong with the script, As the door works fine for me.
Here is the script:
https://gyazo.com/668e0b412ca8f9ad17bf9dcfa7aa8092 -
What solutions have you tried so far?
I looked on Youtube, But could not find anything
Looks more like you need to debug your code more over relying on YouTube tutorials to solve this problem for you. It’d probably also be better to do this problem in reverse: destroy the door if they own the pass, over adding one if they don’t.
Any console errors you get from this code?
I get no Console errors From this piece of code.
Also i’m not experienced in Using Lua So i rely mostly on youtube.
I’d really recommend handling this in Script and then have a RemoteEvent to communicate to the client if it should really show the door or not.
Make sure to have a RemoteEvent in ReplicatedStorage, a Script in ServerScriptService and a LocalScript in preferably StarterPlayerScripts.
Now you’ll need to connect on PlayerAdded in the script and check if the do or do not have the asset:
local players = game:GetService("Players")
local mps = game:GetService("MarketplaceService")
local storage = game:GetService("ReplicatedStorage")
players.PlayerAdded:Connect(function(plr)
if not mps:UserOwnsGamePassAsync(plr.UserId, 7448850) then
storage.RemoteEvent:FireClient(plr)
end
end)
Now you’ll need to connect OnClientEvent in the LocalScript:
local storage = game:GetService("ReplicatedStorage")
storage.RemoteEvent.OnClientEvent:Connect(function()
if not workspace.LocalParts:FindFirstChild("GamePassDoor") then
local door = storage.LocalParts.GamePassDoor:Clone()
door.Parent = workspace.LocalParts
end
end)
Handling MarketplaceService related functions and events on the server is essiential, I really recommend it.