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

Door Isn't Opening for Local Player that Owns Gamepass?

I've created a script which is supposed to make a doors collisions on or off depending on if the player owns the gamepass, and i only want the door to be non collidable for the players that HAVE the gamepass. It doesn't work i think the error is in line 8?

local mps = game:GetService("MarketplaceService")
local id = 8503267
local granted = game.ReplicatedStorage.Events.PremiumAccessGranted
local denied = game.ReplicatedStorage.Events.PremiumAccessDenied

game.Players.PlayerAdded:Connect(function(plr)
	script.Parent.Touched:Connect(function(part)
		if mps:UserOwnsGamePassAsync(plr, id) then
			granted:FireClient()
		else
			denied:FireClient()
		end
	end)
end)

granted.OnServerEvent:Connect(function()
	script.Parent.CanCollide = false
end)

denied.OnServerEvent:Connect(function()
	script.Parent.CanCollide = true
end)

5 comments

0

fire client needs to be received by a local script with OnClientEvent

0

oh ill try something

0

it hasnt worked ive made the local script make the parts collision off it hasnt worked

0

i have just fixed your code

0

there are so many problems with this, check my answer

1 answer

The problem is that you didn't even define who to fire the client to, you put nothing so how will it work? :/

local mps = game:GetService("MarketplaceService")
local id = 8503267
local granted = game.ReplicatedStorage.Events.PremiumAccessGranted
local denied = game.ReplicatedStorage.Events.PremiumAccessDenied	 

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		if mps:UserOwnsGamePassAsync(plr, id) then
			granted:FireClient(plr) -- There used to be nothing in the brackets
		else
			denied:FireClient(plr) -- there was nothing in this too
		end
	end
end)

LocalScript inside starterGui

local granted = game.ReplicatedStorage.Events.PremiumAccessGranted
local denied = game.ReplicatedStorage.Events.PremiumAccessDenied

granted.OnClientEvent:Connect(function()
	game.Workspace.VipDoorNameHere.CanCollide = false
end)

denied.OnClientEvent:Connect(function()
	game.Workspace.Doorhere.CanCollide = true
end)

1 comment

0

double check your code first lol

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