Hello, I’ve been trying to make a script that allows you to click a part only when on a specific team, and it will morph you. I already have the morphing but I can seem to get it to work with specific teams using if, then statements. I have attached an image showing the code I’ve tried, are there any obvious mistakes I’ve made, or are there any alternatives?
-Thanks!
usually what i do is go back and just try seeing if actually clicking with the if then statement works. basically just remove the inside stuff and print something to clarify if it actually worked.
uh yk how theres spaces in like if statements and functions… why is there no space for the if statement like
example.OnServerEvent:Connect(function()
-- space, the gap u see it right
end)
that’s called tabbing, some people just don’t do it because it might look better to them. as far as i’m aware it causes no issues to the way your code functions
Add a print statement inside the if statement to see if the statement is running because I don’t know whats wrong. does game.Teams.Hider actually exist aswell?
And where is your script parented?
From what others are saying, indenting does not matter. In some contexts that require indentation, it does, and the linker will properly let you know about errors in cases that do:
I’m not 100% sure where the issue comes from, though. Double-check if the team you create was selected as Auto-Assignable, because that can be an issue if it’s enabled sometimes.
Fun fact: You can highlight multiple lines and press Tab, which will indent every line you select. The opposite direction is Shift + Tab
oh i didnt know that thx for telling
Okay. So after heeding that advice of a few of you, I tried working my way through using Print() to eventually figure out the issue, and in all honesty I never did but the script does work as intended. Here is what the script looks like now for anyone interested in analyzing the difference. Thank you all for the support!
FYI, Model:SetPrimaryPartCFrame is deprecated. It was superseded by Model:PivotTo. It is not recommended that you continue to use SetPrimaryPartCFrame
as it was discovered to cause gradual malformation of the assembly by floating-point errors. I know that this was stated somewhere in an official post by Roblox, but for now, you can see it in action from this post.
Actually, there is one more thing I’ve run into, which is this code only checks for the player to be on the correct team once, and I’m struggling with setting up a loop. I’ll also clarify that I’m looking for when the player changes teams, I want the script to execute the code if you meet the condition at any point in the game, not JUST if you started as team blue when you joined. Any thought?
I changed it to that, thank you!