Anorack
(Bartosz)
June 6, 2020, 10:37pm
#1
Hey everyone.
I’ve done some messing around and I am still not able to find out what’s causing this error.
Any help would be appreciated.
This code right here keeps coming back to this error code: Workspace.Game.Scripts.Main:89: attempt to index nil with ‘Team’
function regionVisualEffect()
if Player.Team == RedTeam then
regionVisual.Transparency = 0
regionVisual.Color = Color3.fromRGB(0,0,255)
tween:Create(regionVisual,TweenInfo.new(1),{Transparency = .9}):Play()
1 Like
Moonvane
(Moonvane)
June 6, 2020, 10:38pm
#2
it means you didnt define the variable “Player” in line 2
2 Likes
Anorack
(Bartosz)
June 6, 2020, 10:40pm
#3
I probably should have included this, but figured I didn’t need it. I did define Player above it.
The actual full code:
local Player = game:GetService("Players").LocalPlayer
local RedTeam = game:GetService("Teams")["Red Team"]
function regionVisualEffect()
if Player.Team == RedTeam then
regionVisual.Transparency = 0
regionVisual.Color = Color3.fromRGB(0,0,255)
tween:Create(regionVisual,TweenInfo.new(1),{Transparency = .9}):Play()
1 Like
Moonvane
(Moonvane)
June 6, 2020, 10:41pm
#4
then it is because you put it in a regular Script, where there is no such thing as LocalPlayer. LocalPlayer only exists when written in a LocalScript
1 Like
Anorack
(Bartosz)
June 6, 2020, 10:42pm
#5
I see, thanks for the help. How would I go about fixing this without having to put it into a localscript?
1 Like
Moonvane
(Moonvane)
June 6, 2020, 10:43pm
#6
game:GetService("Players").PlayerAdded:Connect(function(Player)
if Player.Team == RedTeam then
regionVisual.Transparency = 0
regionVisual.Color = Color3.fromRGB(0,0,255)
tween:Create(regionVisual,TweenInfo.new(1),{Transparency = .9}):Play()
end
end)
6 Likes