I’m looking for someone to assist me with something. So I’ve enabled it so people when they go over the SpawnLocation, will be teamed but on the team, I’ve added some tools so people on the team can have tools. Is there a way that I can make it so people will be given the tools that are in the team? (or make it so when they go over the SpawnLocation, they are respawned?) p.s. I hope this isn’t confusing lol.
So basically when a player touches the spawn, you want to give them tools?
Exactly, the tools that I’ve already put on the team which anyone could get but they’d have to reset which is just a bit annoying for me. Really all I simply need is a script that will just respawn them when they join the team unless there is another option?
What you could do is put a script in the spawn location, and write the following:
script.Parent.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid") then
local player = game.Players:FindFirstChild(part.Parent.Name)
player:LoadCharacter()
end
end)
1 Like
When the player touches the SpawnLocation
, you can detect it and give it the tool
local Tool = game:GetService("ServerStorage").Tool
local SpawnLocation = script.Parent
SpawnLocation.Touched:Connect(function(hit)
-- Verify that the parent of the part is the player and that he is on that team --
local Plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if not Plr or Plr.TeamColor ~= SpawnLocation.BrickColor then return end
-- Verify that the player does not have the tool in StarterGear --
if not Plr.StarterGear:FindFirstChild(Tool.Name) then
Tool:Clone().Parent = Plr.StarterGear
end
-- Verify that the player does not have the tool in Character or Backpack --
if not Plr.Character:FindFirstChild(Tool.Name) or not Plr.Backpack:FindFirstChild(Tool.Name) then
Tool:Clone().Parent = Plr.Backpack
end
end)
Sources: Touched, FindFirstChild, StarterGear
1 Like
Thank you for your help! Really appericiated.
local teams = game:GetService("Teams")
local players = game:GetService("Players")
local rs = game:GetService("ReplicatedStorage")
local toolRed = rs:WaitForChild("RedTool")
local toolBlue = rs:WaitForChild("RedTool")
players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
if player.Team == teams.Red then
local clone = toolRed:Clone()
clone.Parent = player:WaitForChild("Backpack")
elseif player.Team == teams.Blue then
local clone = toolBlue:Clone()
clone.Parent = player:WaitForChild("Backpack")
end
end)
end)
Alternatively this would be how you can give players of different teams different tools.