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

How do I Make My Gamepass "If" Statement Work?

Asked by 4 years ago

I typed this script to make a local part turn off can collide so that player can walk through the door. All of that code works, But the if statement doesn't work.

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

local cavePart = Instance.new("Part",game.Workspace)
cavePart.CanCollide = true
cavePart.Position = Vector3.new(91.13, 2, 7)
cavePart.Size = Vector3.new(1.75, 14, 14)
cavePart.Anchored = true
cavePart.Transparency = 0.5
cavePart.Name = "CavePart"

while wait(10) do
    print("Checking")
    if MarketPlaceService:UserOwnsGamePassAsync(player.UserId, 8023068) then
        print(player.Name.." has the gamepass!")
        cavePart.CanCollide = false
        cavePart.BrickColor = BrickColor.new("Lime green")

    else
        cavePart.CanCollide = true
        cavePart.BrickColor = BrickColor.new("Persimmon")
    end
end

What did I do wrong?

0
It doesnt look like u did anything wrong. User#29913 36 — 4y
0
I know, but the cavePart just stays red. :/ MasonTheCoolBean8 -2 — 4y

Answer this question