Explanation: So I'm trying to write a simple code but the code doesn't seem to work. So I have 3 teams in the game named "Hospital Staff", "Patient" and "Guest". The player will be in team "Hospital Staff" only if they are in the group and have certain rank. They will be "Patient" if they are in the group and are only a member of it. Player will be in team "Guest" if they are not in the group.
Problem: I tried to clone a tool named "KeyCard" from ServerStorage to Player's Backpack but it seemed to be glitched. I tried to print "Cloned" if the tool is cloned in the Backpack and "Not Cloned" if it is not. What surprises me is that when I joined the game, the script printed "Cloned" but I did not have any tool in my Backpack. Then I tried to check my Backpack in explorer but could not find as well.
Here is my ServerScript located in ServerScriptService named "TeamAssignServer" :
local Players = game:GetService("Players")
local Teams = game:GetService("Teams");
local Hospital_Staff = Teams["Hospital Staff"]
local Patient = Teams.Patient
local Guest = Teams.Guest
Players.PlayerAdded:Connect(function(Player)
if(Player:IsInGroup(5786709)) then
print("Player Is In Group: Robloxia City Hospital")
print("Player's Rank Is: "..Player:GetRankInGroup(5786709))
local Rank = Player:GetRankInGroup(5786709)
if Rank > 1 then
Player.TeamColor = Hospital_Staff.TeamColor
print("Team Changed, Player's Team Is Hospital Staff")
local KeyCardClone = game.ServerStorage.KeyCard:Clone()
KeyCardClone.Parent = Player.Backpack
if Player.Backpack:FindFirstChild("KeyCard") then
print("KeyCard Cloned")
else
print("KeyCard Not Cloned!")
end
elseif (Rank == 1) then
Player.TeamColor = Patient
print("Team Changed, Player's Team Is Patient")
end
else
Player.TeamColor = Guest
print("Player Is Not In Group: Robloxia City Hospital!")
print("Team Changed, Player's Team Is Guest")
end
end)

1 comment
Thanks. I actually tried that but i put repeat wait() until Player instead of Player.Character. Thanks for the fix too tho, didn't notice it