Issues with script

I would like to make a script where a certain team can have a shift to run ability, I have tried putting one together but it didn’t work!

This is what I have so far, Screen Shot 2021-07-01 at 1.29.23 PM
and it is supposed to only allow the Bright Red team to access the script though it allows everyone instead of just that one team for some reason. The script also enables a script bellow It which has the actual shift to run script which works.

4 Likes

Well, returning doesn’t return the whole script, so you’re origional function doesn’t do anything. Just do:

function onPlayerEntered(player)
   if player.Team = game:GetService("Teams"):FindFirstChild("Team") then
      player.CharacterAdded:Connect(function(char)
          --Clone script over
      end
   end
end

game.Players.PlayerAdded:Connect(onPlayerEntered)

On this part the equal sign and the “then” shortly after gets a red line under it, is there anything I can do to fix it?

Ah, my bad, I didn’t put 2 == signs. I assume you’re slightly new to scripting, so:
if player.Team == game:GetService("Teams"):FindFirstChild("Team")

So this is what it should look like correct? Also the char has a blue line I don’t know what to do abt that.

You should take away the ‘end)’ before the repeat wait and put it at the bottom

If I am correct I think the blue line means the word you put is undefined(sometimes.) If you say something like “char” and don’t have a “char” variable then it should have a blue line. I am not sure because I haven’t used light theme for a while and I am using dark theme.

Do what Ianhc said:

Blockquote
or you can move:
"local s = script.SprintScript:Clone()
s.Parent = char
s.Disabled = false
"
above the “end)” on the line above it.

The reason for this is because the line with “char” that is underlined in blue does not know what char is. That is because the code block where it says what “char” is in “player.CharacterAdded:Connect(function(char)” is only defined in that code block so it would be undefined and not pass char through every code block. Like I said, you need to move the script part I put in quotes into the code block that defines char: the code block that starts with “player.CharacterAdded:Connect(function(char)” so it knows what char is. Sorry for the bad explaining, I don’t explain that well.