I'm Trying To figure out how to do it but it's not working, can Someone give me a help, I want to script when player touches the brick and if he has the gamepass he gets a trail, Thanks!

game.Players.PlayerAdded:Connect(function(plr)
	if game:GetService("MarketplaceService"):PlayerOwnsAsset(plr,5647766) then
		
		 script.Parent.Touched:Connect(function(parttouched)
        local humanoid = parttouched.Parent:FindFirstChild("Humanoid")

    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
		
	else 
		print(plr.Name .. " player doesn't have game pass")
		end
		end)
	end
	end)

3 comments

0

You code will connect an new event for every player that has the game pass. Meaning you give it out to all players.

0

I'm Getting Errors That I Have To Use PlayerOwnsAsset, Even Though, I'm Using, Why?