Hello,im making a script that gives you a tool if you own a gamepass The thing is that in my game you change teams, and i need to check if the player is on that team to give him the tool, which works very well but, if you hold the tool the loop will act and set the parent to the player backpack, which makes impossible to hold the tool.
So how do i make this loop wait until the player is on that team and not loop parent backpack the tool?
Line of my code im referring to:
if haspass == true then
while wait() do
if player.TeamColor == BrickColor.new("Ghost grey") then
player.Parent = player.Backpack
end
end
end
end)
My full code:
local mps = game:GetService("MarketplaceService")
local replicatedstorage = game:GetService("ReplicatedStorage")
local tool = replicatedstorage:WaitForChild("MartilloDorado")
local gamepassid = 11019773
game.Players.PlayerAdded:Connect(function(player)
wait(1)
local haspass = false
local success,message = pcall(function()
haspass = mps:UserOwnsGamePassAsync(player.UserId, gamepassid)
end)
if haspass == true then
while wait() do
if player.TeamColor == BrickColor.new("Ghost grey") then
player.Parent = player.Backpack
end
end
end
end)
