Script works only in studio, and when in-game throws this weird error (UPDATE: I FIXED IT IT WAS A VIRUS)

I am having an issue with a script I made (PlayerGUI) which involves making the gui visible, it works fine in studio but not in -game. Here is the error which I get.

local goal1 = workspace.goal1
local goal2 = workspace.goal2
local ball = workspace.TPS
local player = game.Players.LocalPlayer
local ball = game.Workspace.TPS 
local team = game.Teams

ball.Touched:Connect(function(part)
	if part == goal1 and player.Team == game.Teams.Scousers then
		
		game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
	
		player.PlayerGui.EmotesGUI["Open/Close"].Visible = true
		player.PlayerGui.Start.Menu.Visible = false
		wait (10)
		
		player.PlayerGui.EmotesGUI.Animations.Visible = false
		player.PlayerGui.EmotesGUI.Animations.Visible = false
		player.PlayerGui.Start.Menu.Visible = true
		player.PlayerGui.EmotesGUI["Open/Close"].Visible = false
		game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
		
	elseif part == goal2 and player.Team == game.Teams["Les Parisiens"] then
		game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
		player.PlayerGui.EmotesGUI["Open/Close"].Visible = true
		player.PlayerGui.EmotesGUI.Animations.Visible = true
		player.PlayerGui.Start.Menu.Visible = false
		wait (10)
		player.PlayerGui.EmotesGUI.Animations.Visible = false
		player.PlayerGui.EmotesGUI.Animations.Visible = false
		player.PlayerGui.Start.Menu.Visible = true
		player.PlayerGui.EmotesGUI["Open/Close"].Visible = false
		
		game:GetService('StarterGui'):SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
	end

end)

EDIT: This script that I made works in game as well.

local goal1 = workspace.goal1
local goal2 = workspace.goal2
local ball = workspace.TPS
local player = game.Players.LocalPlayer
local ball = game.Workspace.TPS 
local team = game.Teams


ball.Touched:Connect(function(part)
	if part == goal1 then
		game.ReplicatedStorage.LiverpoolParticles:Clone().Parent = workspace
		game.ReplicatedStorage.RedsBubbles:Clone().Parent = workspace
		wait (10)
		workspace.LiverpoolParticles:Destroy()
		game.Workspace.RedsBubbles:Destroy()
		
	elseif part == goal2 then
		game.ReplicatedStorage.ParisParticles:Clone().Parent = workspace
		game.ReplicatedStorage.ParisBubbles:Clone().Parent = workspace
		wait (10)
		workspace.ParisParticles:Destroy()
		game.Workspace.ParisBubbles:Destroy()
	
	end
end)

Not sure if it’s related since I only glanced at the error but ServerStorage can only be accessed from server scripts.

1 Like

I dont have server storage in my scripts

That’s weird considering ServerStorage is being referenced in the error, perhaps it’s a plugin/script you’re unaware of?

The error is coming from line 7 in a script called EmotesHandler, which is either being inserted by another script during gameplay or is in StarterPlayerScripts. If your issue is related to the error, then you need to reference that script rather than the code that you posted.

use repecated storage or waitforchild or getservice