Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how to enable gui using a normal script in serverscriptservice?

I have an on on touch function in a script located in serverscriptservice and I would like to enable a gui in it. I can't figure out how to do this since I only have experience showing guis with local scripts.

Here was my original code which did not work

			local gui = hit.Parent.PlayerGui:FindFirstChild("Gui")
			if gui then
				gui.Enabled = true
			end

How would I navigate to the playergui through the ontouch? I have also thought of cloning the gui into the playergui, but I am not sure how I would do that and if that would even work.

Any help or advice is appreciated, thank you

1 answer

✓ Accepted answer

Hit.Parent is the character of the player, not the player instance.

try this instead:

local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
local gui = plr.PlayerGui.Gui

if gui and plr then
	gui.Enabled = true
end

Note: this script was not tested

2 comments

0

Using the :Clone() method may be a viable option, or you can fire a RemoteEvent to the Client.

0

It worked great, thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.