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

how do i make a premium only door that prompts premium if you dont have it?

Asked by 5 years ago

i tried this and everything seems ok but nothing works?

01local Players = game:GetService("Players")
02local player = Players.LocalPlayer
03local MarketplaceService = game:GetService("MarketplaceService")
04 
05script.Parent.Touched:Connect(function(h)
06    local hum = h.Parent:FindFirstChild("Humanoid")
07    if hum ~= nil then
08        if player.MembershipType == Enum.MembershipType.Premium then
09 
10            script.Parent.CanCollide = false
11            wait(0.1)
12            script.Parent.CanCollide = true
13 
14        else
15            -- prompt premium purchase
View all 21 lines...

1 answer

Log in to vote
1
Answered by
P100D 590 Moderation Voter
5 years ago
Edited 5 years ago

Since this isn't a LocalScript, Players.LocalPlayer won't work, as this method only works in a LocalScript. (If this is a LocalScript, the script won't run at all if it's in Workspace)

To find the player, you can use Players:GetPlayerFromCharacter()

Example:

1script.Parent.Touched:Connect(function(part)
2    local humanoid = part.Parent:FindFirstChild("Humanoid")
3    if (humanoid ~= nil) then
4        player = game:GetService("Players"):GetPlayerFromCharacter(humanoid.Parent)
5    end
6end)
Ad

Answer this question