Help give gui to someone when tool is equipped

I’m trying to make some sort of script that gives a certain GUI to players when a tool is equipped, by cloning the Gui and then setting its parent to the PlayerGui, there’s only an issue. It doesn’t give any GUI. The script outputs no error, nor in F9 Console. Does anyone know how to help?

local player = game.Players.LocalPlayer
script.Parent.Equipped:Connect(function()
	local clone = game.ReplicatedStorage.ScreenGui:Clone()
	clone.Parent = player.PlayerGui
	script.Parent.Unequipped:Connect(function()
		clone:Destroy()
	end)
end)

there’s no need to clone the screenGui, since it’ll already be in the player (not the character).

How about just accessing the gui trough the PlayerGui and toggling the Enabled property?

Edit: Oh sorry lol if you put the gui in starterGui Then it will be in the player

is ui enabled ?
(Too short message)

Yes, it is, but it is in ReplicatedStorage.

The issue is that the player isnt specifed so the game doesn’t know what to do.
(The server doesnt know what to do with the variable because it doesnt know who to give the GUI to)

I don’t want to put it inside PlayerGui because people with the intent of exploit can easily enable it with the use of Dev Explorer or whatever it’s called.

local player = game.Players.LocalPlayer

Isn’t LocalPlayer alright? (It’s a localscript)

that’s not what i meant, i edited the post, read it.

It is alright, but the server doesnt know who to give the GUI too.

i just copied this script and used random tool and its worked

It’s nothing on the server, it’s all on a LocalScript because then the Gui will enable a television called with a remote event.

can you show explorer screen of this ui ?


Just in case I’m also gonna link a video of the issue. By the way, the explorer is like this.
image

the word clone isnt recognized in the unequipped function.

image
That’s a picture of the output. Nothing but only the few plugins I have.

if it isnt recognized then why output is clear ?

Yeah, the output should be erroring “clone”, also it’s not erroring because the unequip function is inside the equip function, so there’s no need to return the “clone” variable.

I did same thing in my baseplate (check if ui is Enabled and frame visible)

Baseplate.rbxl (39,6 KB)

I don’t know. It just got underlined. Thought that will be an useful info.

Also, I tried it too and it works perfectly: