Giving players on a team specific tools

Hey there,

I am currently developing a game and it has a roleplay aspect. So when a player joins a team they should receive specific tools. Currently the script is not working and i am not getting output errors.

One of the solutions i tried was the :GetPropertyChangedSignal() event but that didnt work.

Here is the current script that i am using:

local teams = game:GetService("Teams")
local serverStore = game.ServerStorage
local hk416Mod = serverStore["HK416 Mod"]
local player = game.Players.LocalPlayer

local function checkTeam()
	if player.Team == teams["The Delta Brotherhood"] then
		local hk416ModClone1 = hk416Mod:Clone()
		local hk416ModClone2 = hk416Mod:Clone()
		if player.StarterTools and player.Backpack then
			hk416ModClone1.Parent = player.StarterTools
			hk416ModClone2.Parent = player.Backpack
		else wait(10)
			print("Checking if player has a backpack or startertools yet...")
			if player.StarterTools and player.Backpack then
				print("Player's startertools and backpack have loaded, giving tools...")
				hk416ModClone1.Parent = player.StarterTools
				hk416ModClone2.Parent = player.Backpack
			else
				print("Player still does not have a backpack or startertools...")
				player:Kick("Your backpack and/or startertools did not load, if this problem happens again please report the bug.")
			end
			end
	end
end

while true do -- Using a while true do loop since it will be the only code that needs to run after the functions are created
	checkTeam()
	wait(1)
end

I am not too sure why the players dont receive the tools.
This script is located within the ServerScriptService.

Thanks for the help! :slight_smile:

1 Like

since this is in a Server Script remember you can’t refer to the Local Player, only on LocalScripts!

2 Likes

Your approach with the GetPropertyChangedSignal is better than what you are doing currently.

Plus you should be using Players.PlayerAdded for server side code.

The teams service has an event called: “PlayerAdded”, you should be connecting that event to a function like so:

local TeamsService = game:GetService("Teams")

local Team = TeamsService["The Delta Brotherhood"]

Team.PlayerAdded:Connect(function(Player) --Gives you access to the player
	--Clone the weapons into the Player's Backpack and StarterTools
end)
2 Likes

I have attempted to put it in a local script, but since the tool is in the ServerStorage, the local script cant access the tool.

Thanks for the help.

I also had another error i was doing StarterTools instead of StarterGear.

I was also not aware of this.

Thanks again! :slight_smile:

2 Likes

Why would it even need to be run on a localscript?

1 Like

Oh,

Because the server script wasnt working so i was just testing to see if it would work on the client side.

But this is getting off topic, if you wish to discuss further, please PM me.

1 Like