i might as well make it to where if a prisoner touches the baseplate they become criminal
i’m having trouble understanding why the original script doesn’t work change change the part to an invisible region and it should work
Try the download I made, and see if my code works good for your needs.
Its really all about limiting the touched and touchended to the humanoid, and keeping track of that.
Wait, what do you think is the issue?
@Fimutsuu what is a invisible region?
and @SelDraken i will try that but can you send me the download?
i think it’s the fact that he has a huge baseplate and he just checks for TouchEnded
on it thinking it will only fire when you leave it’s boundaries
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