Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I make different teams spawn with a custom character?

Asked by 4 years ago

So my buddy told me that this would be hard so I went to this site again. Let's say I have 2 models that is R6, one model for each team. How can I make players spawn with those models though? Any help would be appreciated

0
Your buddy isn't right. Sonnenroboter 336 — 4y
0
Uhhh thanks for the link but I already made a custom character for each team, What I mean is how I can assign custom characters for different teams Simpletton 82 — 4y
0
Well, the guy isn't supposed to be entirely right. DeceptiveCaster 3761 — 4y
0
ok Simpletton 82 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

This code does not entirely work, but this is pretty much the basis of what you're asking for. You could change it and make it work. You'll need a localscript to make the camera look at the custom character humanoidrootpart and blah blah blah. I only posted this as an answer because this can't fit in the comments. I could fix it myself, but it would take 2-3 hours. Good scripts take time.

function teamFromColor(color) 
for _,t in pairs(game:GetService("Teams"):GetChildren()) do 
if t.TeamColor==color then return t end 
end 
return nil 
end 

function onSpawned(plr) 
local characters = teamFromColor(plr.TeamColor):GetChildren() 
for _,c in pairs(characters) do 
if c:IsA("Model") and c:FindFirstChild("HumanoidRootPart") then
c.Archivable = true
local x = c:Clone()
x.Parent = workspace
x.HumanoidRootPart.CFrame = plr.Character.HumanoidRootPart.CFrame
plr.Character = x
end
end 
end 

function onChanged(prop,plr) 
if prop=="Character" then 
onSpawned(plr) 
end 
end 

function onAdded(plr) 
plr.Changed:connect(function(prop) 
onChanged(prop,plr) 
end) 
end 

game.Players.PlayerAdded:connect(onAdded)
0
can you fix it plox Simpletton 82 — 4y
Ad

Answer this question