I have a normal script under StarterPlayerScripts that’s supposed to get detect if your team is Team1 (yes I have the player’s team seat to Team1), but for some reason nothing happens when I play test the game, no errors or anything
a bulleted to be clear because sometimes people don’t read what I write thoroughly
NORMAL script
script under StarterPLAYERScripts
the player’s team is Team1
nothing printed and no errors in output
if script.Parent.Parent.Team == "Team1"
then
print("team1")
--and do other stuff
end
I also tried just doing a simple print("hello world!") and nothing happened
muahaha with my master script hijacking skills I made this
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
if player.Team == game.Teams.Helthee then
print(player.Team)
--do stuff
end
end)
If the script’s under StarterPlayerScripts, why are you doing script.Parent.Parent?
Also, you should compare the Team with a team object, not a string.
Edit: Nevermind, it’ll be parented to PlayerScripts, inside the Player.
The only scripts that will run in StarterPlayerScripts are LocalScripts and they’re the only ones that should be in there as well. StarterPlayerScripts populates PlayerScripts, which is a client-side container under the Player object for running code much like ServerScriptService is for the server.
When you are checking for the player’s team, Team == "Team1" will fail. The team property of the player is a reference to a team instance and an instance cannot be equal to a string. The way to fix this is either to add .Name to Team so that you’re comparing the name of the team instance to a string or changing the second operand to reference the actual team at game:GetService("Teams").Team1.
For PlayerAdded, LocalScripts will only start executing after the server finishes replicating the initial DataModel snapshot. PlayerAdded for the current client will already have fired by then, so when a LocalScript connects to PlayerAdded, the current client will have already been in the server. When needing to act with the LocalPlayer, just find it under the Players service. PlayerAdded in LocalScripts is only for working with when other players join the server.