Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Cloning models and Team Switch?

OK, I am getting really frustrated, I have been working on a game for 4 months and it is nearly actually playable except from two things. I am not the best Scripter but I have been dealing with it well and been learning along the way.

First of all, I want to create a script that it starts as them being a "Spectator" it waits 30 seconds then changes the player's team to "Players" then after 180 second the player switches back to "Spectator" and it loops, meanwhile the Arena they are in will reset

So I tried to do:

while true do wait(30) game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(char) player.Team = game.Teams.Players end) wait (180) game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(char) player.Team = game.Teams.Spectators end) end) end) end

This didn't work and I can't do model regen, (The model is game.Workspace.Arena) This has the exact same timings as the switch team script.

Sorry to be a pain, I have been trying to get help for hours of days

Sorry the code didn't paste very well, I messed up, here it is properly:

while true do
	wait(30)
	game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(char)
		player.Team = game.Teams.Players
	end)
	wait (180)
	game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(char)
		player.Team = game.Teams.Spectators
	end)
end)
end)
end

1 answer

✓ Accepted answer

Try this:

while true do
	wait(30)
	for i,p in pairs(game.Players:GetPlayers())do
		p.Team=game.Teams.Players
	end
	wait(180)
	for i,p in pairs(game.Players:GetPlayers())do
		p.Team=game.Teams.Spectators
	end
end

2 comments

0

Thanks man that worked, by any chance do you know how to clone a model, delete it then replace it? I only know a small amount of that and I can't do it

0

Never mind, my bad, I put game.Workspace.Arena instead of something else :/ Thanks for the help man

This discussion is preserved as it was. New answers, comments, and votes are closed.