Hello guys, I have a Team name: "Alpin doctor" and this name have a space between the two words and then the script don`t work. (The scripts open a door when a player in the team touch it)
If I let a space between the words the second line have a problem.
I tested also this: game.Teams.['Alpine doctor']
and this game.Teams.('Alpine doctor')
and alos this game.Teams.["Alpine doctor"]
and this game.Teams.'Alpine doctor'
Here is the script:
local team = game.Teams.Alpine doctor local door = script.Parent door.Touched:connect(function(hit)
Here is the full script
ocal team = game.Teams.Alpine doctor local door = game.Workspace.STOPP.medicdoor door.Touched:connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr.Team == team then door.CanCollide = false door.Transparency = .5 wait(1) door.CanCollide = true door.Transparency = 0 else humanoid.Health = 0 end end end)
Thanks for any help in previous
You haven't gotten the syntax right, game.Teams["Alpine doctor"]
is the way to index a name that dot syntax won't work for, just like writing table[1]
and not table.[1]
Alternatively, game.Teams:FindFirstChild("Alpine doctor")
Hello,
Here's a quick answer to your question.
To call anything with a space we do,
game.Workspace["Alpine Doctor"]
Notice how there is no "." between Workspace and [Alpine Doctor]. Here's how we would fix your first example,
local team = game.Teams["Alpine doctor"]
I hope this clears up any confusion :)