Its already in the post
but I will link it again
TeamChange.rbxl (48.2 KB)
Have you ever tried to use a remote event to switch team?
the problem isnât switching teams that perfectly works its just that the moment he will move in the baseplate it will change teams
guys i have an idea:
i had a similar problem once and it might have a similar solution if i just change it!
Lets say you want your story:
local function onPartTouched(otherPart)
local character = game.Players:GetPlayerFromCharacter(otherPart.Parent)
if character and character.Team then
if character.Team.TeamColor == BrickColor.new("Really red") then -- replace "Really Red" as the team color that he has to be in for the part to not change
-- replace "e" with your team name to change it to.
local teamToJoin = game.Teams:FindFirstChild("e")
if teamToJoin then
character.Team = teamToJoin
else
warn("Team not found. Probably wrong typed name.")
end
end
end
end
local function onPartTouchEnded(otherPart)
local character = game.Players:GetPlayerFromCharacter(otherPart.Parent)
if character and character.Team then
end
end
script.Parent.TouchEnded:Connect(onPartTouched)
script.Parent.TouchEnded:Connect(onPartTouchEnded)
What i used:
I used a regular script, the directory is:
script.Parent -- leads to the part that is the touch thing
Update: i just figured out there is a small problem with the TouchEnded, i have a R6 avatar so i dont know if that causes the problem but you will probably have to put the part IN front of the prison.
literally make a huge part over the prison â turn its transparency to 1 and turn CanCollide off and put the script in it
guys i found the solution, instead of using .touchended or spending like 20 minutes trying to script this we can just make the parts around it run the command .touched like the baseplate!
Great that you have found something to fix your issue with team changing
however we can make one thing better:
someone with exploits might just like teleport or fly so they dont touch the baseplate, so to double check we could make it to where once the part is touched, we could make it constantly check that the player is touching the part and if they aree not they become criminal
Try that:
--[[Server Side]]--
--Create a remote event and place it on ReplicatedStorage
local remote = --Create the remote on RS
part.Touched:connect(function(SwitchTeams)
repeat wait() until part.TouchEnded end
if SwitchTeams.Parent:FindFirstChild("Humanoid") then
local PlayerTeam = game.Players:GetPlayerFromCharacter(SwitchTeams.Parent)
remote:FireClient(PlayerTeam,remote)
end
end)
--[[ClientSide]]
local rs = game:GetService("ReplicatedStorage")
local remote = rs.RemoteName
remote.OnClientEvent:Connect(function(playerteam)
if playerteam.Team == game.Teams.red then
playerteam.Team = game.Teams.Blue
end)
first of all this doesnât fix the problem because he has no issue changing teams PLUS it will make it so the team only changes for the player so i donât know what youâre thinking making this
I thought he was doing that just for the player
the whole point of this was to make it that if the player stops touching a part then they switch teams
Thats what my project does. When they stop touching the green part, they become criminals if they were prisoners.
yes and the part canât be a baseplate because the moment you move you fire the TouchEnded
so it needs to be a huge part the covers the whole region
well thank you all for helping me with super annoying problem and now that it is solved i will deltete this post soon
wait so that is what the touch ended event does?
You really should post what your solution was, and leave the post up, so it can help others who might have the same sort of problems
yes because your feet leave the plate so the event fires
THAT SOLVES MY ENTIRE PROBLEM! I THOUGHT IT MEANT IT FIRES WHEN YOU STOP TOUCHING THE PART ITSELF, not just a certian spot takes deep breath thank you so much