#how do i store and detect team changing
70 messages · Page 1 of 1 (latest)
Create your teams first I mean
Then place a script like this in serverscriptservice
local Teams = game:GetService("Teams")
-- Function to handle team change
local function onTeamChanged(player)
local playerTeam = player.Team
if playerTeam then
print(player.Name .. " changed to team: " .. playerTeam.Name)
-- Add your logic here, e.g., update stats, notify other players, etc.
end
end
-- Listen for players joining
game.Players.PlayerAdded:Connect(function(player)
-- Detect initial team
onTeamChanged(player)
-- Listen for changes in the player's team
player:GetPropertyChangedSignal("Team"):Connect(function()
onTeamChanged(player)
end)
end)
That should work, team scripts are pretty easy to maneuver if u know them
is it ai generated, if it is then ai generated me almost the same thing before making a post here
I don't use ai
interestinh
This is a basic team script
I have experience in this since it's what I mostly do
Detects and stores them
🙃
anyways it doesn't work
wdym "same name"
It
What is the name for ur team script u have
It's always the same?
Make sure it's the same
No no not that ik that
How is it not working it's the same I have in my game smh
You must have something interfering with it
U have a team script already right
there's no scripts handling teams
so that's not the issue
Not scritp
I mean do u have it created
Already
LOL
I MESSED UP
Sorry I checked where i got it from
Place it in starterplayerscripts
Sorry I read it wrong
my script must be a serverscript
I said serverscriptservice which is wronggggg
local scripts wont work
Oh ok, u want it to start an event or announce when someone switches a team
** You are now Level 4! **
Notify basically?
how is this script is even going to work when local Teams = game:GetService("Teams") doesn't work with localscripts
It does
Basically
As a said I read it wrong at first but it still requests teams and applies the lines of code below
To store and detect what u want
teams service is not accesible through local scripts because it's a server sided service
But I can maybe make it so it work with serverscriptservice if u want
It's working in the server remember not with teams. It making a code so teams just announces or notify
Is that not what u want?
That way it can be server sided
If it's just announcing what a team is switched
The point is, you've said to put it in starterplayerscripts which wouldn't even work since you can't access services like Teams through a local script
and im asking how do i store and detect, i don't want a full ready script since im able to script it by myself
Sorry I accidentalli poop on the floor men. Was rushing to the bathroom give me secønd
Oh ok
Well that's easy