So i want a script that detects if a player changed to a team / spawn on a team, and then delete an especific tool. i really don’t know that much in scripting but atleast i know i have to insert a script that does such thing, any help?
local Team = game:GetService("Teams")["Example Team"]
if Player.Team == Team then
-- stuff here
end
(sorry for grammatical issues or spelling english is not my main language.)
local Team = game:GetService("Teams")["Example Team"]
if Player.Team == Team then
if Player.Character:FindFirstChild("ToolName") then
Player.Character:FindFirstChild("ToolName"):Destroy()
elseif Player.Backpack:FindFirstChild("ToolName") then
Player.Backpack:FindFirstChild("ToolName"):Destroy()
end
end
here you go! had to do it so it would find the player and character before checking for the tool
local Team = game:GetService("Teams")["Example Team"]
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if Player.Team == Team then
if Character:FindFirstChild("Tool") then
Character:FindFirstChild("Tool"):Destroy()
elseif Player.Backpack:FindFirstChild("Tool") then
Player.Backpack:FindFirstChild("Tool"):Destroy()
end
end
end)
end)
forgot to do it so it checks if you’ve changed roles, oops.
pretty sure this one should work
local Team = game:GetService("Teams")["Example Team"]
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if Player.Team == Team then
if Character:FindFirstChild("ToolName") then
Character:FindFirstChild("ToolName"):Destroy()
elseif Player.Backpack:FindFirstChild("ToolName") then
Player.Backpack:FindFirstChild("ToolName"):Destroy()
end
end
Player.Team.Changed:Connect(function()
if Player.Team == Team then
if Character:FindFirstChild("ToolName") then
Character:FindFirstChild("ToolName"):Destroy()
elseif Player.Backpack:FindFirstChild("ToolName") then
Player.Backpack:FindFirstChild("ToolName"):Destroy()
end
end
end)
end)
end)
Still doesn’t work, i think because the tool is not deleted because its a gamepasses, maybe it should be moved from a normal script to inside the other script. here is the script of the gamepass giver
local GamepassId = 13267064
local Tool = game.ServerStorage["Knife"]
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if MarketPlaceService:UserOwnsGamePassAsync(Player.UserId, GamepassId) then
if Player.Backpack:FindFirstChild("Knife") then
else
local ToolClone = Tool:Clone()
ToolClone.Parent = Player.Backpack
end
end
end)
end)
local GamepassId = 13267064
local Tool = game.ServerStorage["Knife"]
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.UserId, GamepassId) then
if Player.Backpack:FindFirstChild("Knife") then
else
local ToolClone = Tool:Clone()
ToolClone.Parent = Player.Backpack
end
else
end
end)
end)