Ive been working on a goal scoring system, in the script that adds the points when a team scores, i wrote: local players = game:GetService(“Player”)
After a team scores, a remoteevent is fired, to make appear a gui that says Blue/Red Team has scored.
When i join the game to test it, I get this error: The current thread cannot create ‘Player’ (lacking capability WritePlayer)
I dont know what to do, if u could help me, i would appreciate it. Thank you.
Heres the script
local players = game:GetService("Player")
local scoreBoardGui = workspace.Soccer.ScoreBoard
local RedScore = scoreBoardGui.GuiRed.TextBox
local BlueScore = scoreBoardGui.GuiBlue.TextBox
local goalRed = workspace.Soccer.GoalDetectorRed
local goalBlue = workspace.Soccer.GoalDetectorBlue
local ball = workspace.Soccer.Ball
local originalposition = workspace.Soccer.BallPosition
local function score(team)
team.Text = team.Text +1
if score(team) == BlueScore then
game.ReplicatedStorage.BlueScored:FireClient(players)
elseif score(team) == RedScore then
game.ReplicatedStorage.RedScored:FireClient(players)
end
ball.Anchored = true
ball.Position = originalposition.Position
ball.AssemblyLinearVelocity = Vector3.new(0,0,0)
ball.AssemblyAngularVelocity = Vector3.new(0,0,0)
wait(1)
ball.Anchored = false
end
ball.Touched:Connect(function(part)
if part == goalRed then
score(BlueScore)
elseif part == goalBlue then
score(RedScore)
end
end)