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

Why is my VIP door making everyone cancollide on when someone without the pass joins?

Hello, I want to know why my VIP door is cancollide off when I join with me owning the gamepass but when someone else joins, it sets cancollide on for everyone.

Here's the script:

game.Players.PlayerAdded:Connect(function(plr)
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(plr.UserId, 8565645) then
		script.Parent.CanCollide = false
		script.Parent.Transparency = 0.8
	else
		script.Parent.CanCollide = true
		script.Parent.Transparency = 0
	end
end)

The script is in a VIP door and it is a script, not a local script or module script.

Thanks!

4 comments

0

If you want one specific player to be able to walk through, you have to use a LocalScript

0

I changed it to local script and now it doesn't even work for me.

0

I'll give you an answer

0

Okay, thanks!

1 answer

✓ Accepted answer

LocalScript

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local player = Players.LocalPlayer

local badgeId = 8565645

local vipDoor = game.Workspace.VIPDoor -- change this to where your VIP door is located and what the name of it is

if MarketplaceService:UserOwnsGamePassAsync(player.UserId, badgeId) then
	vipDoor.CanCollide = false
	vipDoor.Transparency = 0.8
else
	vipDoor.CanCollide = true
	vipDoor.Transparency = 0
end

Okay so the reason to why your problem occurs is because it's a Server Script (Script). Any changes that you make in a Server Script will happen on the Server and therefore be seen for all players. If you want something to only happen to one specific player, you have to use LocalScripts. But LocalScript's doesn't run in Workspace. So I would recommend if you placed this in StarterPlayer -> StarterPlayerScripts. Now, whatever you change with a LocalScript (that is placed somewhere where it can run) will only change for the Player the LocalScript is associated to.

2 comments

0

Thanks! That really helped!

0

No problem

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