There is so many reasons as to why this may not be working, especially since the output doesn’t provide us with any real deductive information. It’s really hard to help when we only see the events and nothing else, as well as the fact that you haven’t really told us what it’s meant to do.
I would like the very first few lines of your script because according to your code, line 1 is the issue. You can check that or show it to me.
Also, please don’t show an image of the script but copy and paste it, it’ll make it easier, of course not the whole script needs to be pasted.
First, is it a local script or a server script? Also, show me where you defined the variable “background1”. Also show me where you defined the variable “a”. Then I can know the problem.
Fortunately, I have just the answer!
First, create a remoteEvent inside ReplicatedStorage. Call it “ShowGuiOnTouch”
You can make a script inside server script service and put this in:
local myPart = --your part here
myPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
game.ReplicatedStorage.ShowGuiOnTouch:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent)
end
end)
Now put this inside a local script in starter gui:
local gui = --your gui here
game.ReplicatedStorage.ShowGuiOnTouch:Connect(function()
gui.Visible = not gui.Visible
end
There you go! Don’t forget to set as solution if this worked