I made a script so that my donators could get VIP trails but it doesn't seem to work, can anyone see why?
This is where the parts for the script is. Eg the trail and script itself. http://imgur.com/gallery/D6Ezu
This is the script.
local passIDs = { 971425430; 000000000 } function playerHasPass(plr) for _,id in pairs(passIDs) do if game.MarketplaceService:PlayerOwnsAsset(plr, id) then return true end end return false end script.Parent.Touched:connect(function(hit) local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then if playerHasPass(plr) then game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) local trail = game.ServerStorage.Trail:Clone() trail.Parent = char.Head local attachment0 = Instance.new("Attachment",char.Head) attachment0.Name = "trailAttachment0" local attachment1 = Instance.new("Attachment",char.Torso) attachment1.Name = "TrailAttachment1" trail.Attachment0 = attachment0 trail.Attachment1 = attachment1 end) end) else print ("Player doesnt have the pass") end end end)
I'm not very good with scripts, so if anyone could find out, could you send me a script fix and a explanation please?
The way your script is set up now will wait for a player who has the pass to touch the button, then it will give the trail to all future players who enter the server. You need to choose whether you want the VIP to given when they press the button, or when they enter the server, but not both.
Here's an example when they enter the server:
... game.Players.PlayerAdded:Connect(function(player) --When a player enters.. if playerHasPass(plr) then --Check if they have the pass player.CharacterAdded:Connect(function(char) --When their character spawns, give them the VIP trails. local trail = game.ServerStorage.Trail:Clone() trail.Parent = char.Head local attachment0 = Instance.new("Attachment",char.Head) attachment0.Name = "trailAttachment0" local attachment1 = Instance.new("Attachment",char.Torso) attachment1.Name = "TrailAttachment1" trail.Attachment0 = attachment0 trail.Attachment1 = attachment1 end) end end)
And here's one for a button press:
script.Parent.Touched:connect(function(hit) local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then if playerHasPass(plr) then --Do the trail stuff end end end