So, I am trying to make a premium door, you may ask what I mean by a “premium door”.
A premium door is a door that only opens when a player with the premium membership
touches it.
Example: A non-membership player touches the door, but since it has no membership the door
will not open. But if a player with a membership touches the door, it will open.
I am trying to do that but it won’t work, help?
local Players = game:GetService("Players")
local player = Players.LocalPlayer
if player.MembershipType == Enum.MembershipType.Premium then
script.Parent.CanCollide = false
else if player.MembershipType == Enum.MembershipType.None then
script.Parent.CanCollide = true
end
The script doesn’t work because a the local script is located inside of a door, the script is never loaded into any client therefor it does not run, try putting it inside StarterPlayerScripts
It would be wise to use a server script since an exploiter could easily bypass the check.
local door = script.Parent
local Players = game:GetService("Players")
door.Touched:Connect(function(part)
local player = Players:GetPlayerFromCharacter(part.Parent)
if player then
door.CanCollide = player.MembershipType ~= Enum.MembershipType.Premium
end
end)
It works but, when a premium player touches it, the can collide turns off right?
This means that a non-premium player can get in with the help of a premium player.
I want this premium door to work alot like the one in “Flex your account age”
In that case you should handle it locally. I’ll use your script slightly modified.
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local door = game.Workspace.PremiumDoorPart -- Put in the right one
door.CanCollide = not (player.MembershipType == Enum.MembershipType.Premium)