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

Why It Gives The Trail Even Though Player Doesn't Have GamePass? [closed]

Asked by 5 years ago

I Have The Game Pass, And When I Touch Brick, It Gives Me The Trail, This Is What I Wanted to do, But then a player comes, and he also touches the brick and he gets the trail, But he doesn't have The Game Pass, Why?

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local gamePassID = 5647766 -- Change this to your game pass ID 

function onPlayerSpawned(player) 

    local hasPass = false

    -- Check if the player already owns the game pass
    local success, message = pcall(function()
        hasPass = MarketplaceService:UserOwnsGamePassAsync(player.userId, gamePassID)
  print("Has Game Pass for Gun")
    end)

    -- If there's an error, issue a warning and exit the function
    if not success then
        warn("Error while checking if player has pass: " .. tostring(message))
        return
    end

    if hasPass == true then


script.Parent.Touched:Connect(function(parttouched)
        local humanoid = parttouched.Parent:FindFirstChild("Humanoid")
        -- The above is how we check that this a human it's either the Humanoid or nil.
    if humanoid ~= nil then
        local char = humanoid.Parent
        local trail = game.ServerStorage.Blue:Clone()
            trail.Parent  = char.Head
            local attachment0 = Instance.new("Attachment", char.Head)
            attachment0.Name = "TrailAttachment0"
        local attachment1 = Instance.new("Attachment", char.HumanoidRootPart)
            attachment1.Name = "TrailAttachment0"
        trail.Attachment0 = attachment0
        trail.Attachment1 = attachment1
    end
end)



 end
end 

game.Players.PlayerAdded:connect(function(player)
  player.CharacterAdded:connect(function()
    onPlayerSpawned(player)
  end)
end)

-- Connect 'PlayerAdded' events to the 'onPlayerAdded()' function
Players.PlayerSpawned:Connect(onPlayerSpawned)
0
There's absolutely no need for all that mess, simply just check for the passwhen touched, nothing but an if statement Ziffixture 6913 — 5y
0
But I Want To Do If The Player Has Game Pass, To Get The Trail, Not If just touches the part ItzJester2 12 — 5y
0
The guidelines state your question should be your own code, not someone elses. DinozCreates 1070 — 5y
0
My Friend Wrote this for me, So it's my code... ItzJester2 12 — 5y

Closed as Not Constructive by DinozCreates, User#24403, and Gey4Jesus69

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?