I'm using a tool for my game that when you click it, is gonna change the current camera to one of the CCTV cameras in the game and also there is gonna appear a plant of the map. The problem is that the plant of the map doesn't show and I don't know how to solve it. I'm gonna put the script that I put in inside the game (just the important part):
game.StarterPack.Tool.Activated:Connect(function()
game.StarterGui.ScreenGui.ImageLabel.Visible = true
end)
Can someone explain what I'm doing wrong?
Guis run on the client, meaning if you want to script them you should use a local script. Insert a local script into the tool and use this as the script's code:
Players = game:GetService("Players") -- Gets the "Players" service player = Players.LocalPlayer -- Gets the player whose client this script is running on. Since local scripts are replicated to all the clients, each client will have a copy of this script, and this will tell you which client this script is running on. PlayerGui = player.PlayerGui -- The PlayerGui is where a player's gui is stored, and it is parented to the player. If we want to change the player's guis it's best to change it in their PlayerGui. Inside the PlayerGui is everything in StarterGui, which is replicated into their PlayerGui when they join the game. script.Parent.Activated:Connect(function() -- Fires when the tool is activated. script.Parent references the tool which should be the parent of this local script PlayerGui.ScreenGui.ImageLabel.Visible = true -- Makes the image label in their PlayerGui Visible end)
I hope this helped! If this helped don't forget to accept this answer :)