Help with player gui

i have a script where once a key touches an ai/samurai a Gui at the top of the screen tells you you completed that key so the gui turns red meaning u completed it but it wont work, when the key touches the samurai the gui doesnt turn red anyhelp sorry i explained bad tell me if i need to explain better

Player = game.Players.LocalPlayer
UI = Player.PlayerGui
Tc = UI.SoulsCheck

	if hit.parent.Name == "BR Key" then
		Tc.AfterTouch.Red.Visible = true
		Tc.BeforeTouch.Red.Visible = false
1 Like

after touch is a frame of it telling you completed it so it turning red and beforetouch is before you touch the samurai so it doesnt turn red yet both frames are visible but the texts are not visible

Is this a Local Script or a Server Script? And where is the script located at?

Sorry for late response it’s a server script located in server storage in a key

when the red key touches the samurai the top right gui should turn red making it seem like u completed it, if u look in starter gui u can see before touch and after touch, when u touch it the before touch gui which is the one to the right turns invisible and the after touch gui replaced it making it not invisible

Okay. Now firstly, you cannot access the LocalPlayer on a ServerScript. That can only be done on a local script.
Now I do have to ask, are you trying to make a gui turn red for everyone in the game, or just a specific player?

everyone in the game for it to show

1 Like

If you want to show it to everyone you can try looping through all the players, getting the PlayerGui and toggling the Gui’s visibility.

I see now. You want to use remote events in this situation then. Since you want the GUI to turn Red for everyone, it wont be hard to do

Follow the instructions below:
Insert a RemoteEvent inside of ReplicatedStorage, and name it RedGui.
Then go to your script that is inside the key, and use this following code below:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RedGui = ReplicatedStorage:WaitForChild("RedGui")

local Samurai5 = script.Parent

	if hit.Parent.Name == "BR Key" then

Then, insert a Local Script inside of the ScreenGui named SoulsCheck.
In the local script, use the following code below:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RedGuiEvent = ReplicatedStorage:WaitForChild("RedGui")

local Tc = script.Parent
local AfterTouch = Tc:WaitForChild("AfterTouch")
local BeforeTouch = Tc:WaitForChild("BeforeTouch")

	AfterTouch.Red.Visible = true
	BeforeTouch.Red.Visible = false

And you are done

Very very late response but When I touch the samurai with the soul it breaks the tool so the script works but the thing doesn’t turn red, also you said samurai5 = script.parent shouldn’t script.parent be the tool? It should of been samurai5 = game.workspace.Samurai5

Wait, where was your (server) script located at? What was the tool name? Samurai is an object in Workspace?

Sorry I must of messed up, the first script you told me to put I put it in the tool as a server script the tool name is BR key which is where the script is in, the local script is put in souls check

1 Like

As you see samurai is the thing it needs to touch to turn the GUI red and the script called touch script that’s inside the tool is what the first script u told me to insert into the tool I explained that very bad sorry

One of the pictures did not send but it’s the samurai5 in workspace

I see what was the problem. I thought the script was in Samurai which is in workspace. I almost got completely confused when you responded to me just now, but now I know what the problem is.

Now I do need to ask, do you really need the script inside the key? I believe there is no use for the script inside the key. I think the script should be in the Samurai

I put it in the key so I can do script.parent:Destroy() idk how to destroy an item that isn’t a script.parent and I don’t know how to describe something in the back pack of the player

1 Like

What I mean is it’s easier to destroy just by doing script.parent:destroy()

Do I have to move it to the samurai

Okay. Keep the script in your Key tool.
And here is your updated code:

local RS = game:GetService("ReplicatedStorage")
local WS = game:GetService("Workspace")

local RedGui = RS:WaitForChild("RedGui")
local Samurai5 = WS:WaitForChild("Samurai5")

	if hit.Parent.Name == "BR Key" then