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

Inserting A GUI?

I'm making a mainframe for the Pinewood Builders HQ. I made a script for inserting a gui into the localplayer. When I tried it, it didn't work.

Here is my code:

game.Players.localplayer.PlayerGui.InsertInstance:(180091578)

This did not work for me, this is about my first time scripting.

3 answers

✓ Accepted answer

What you're looking for is the InsertService service.

Since I assume this is a normal Script, you can't use LocalPlayer, either

game:GetService("InsertService"):LoadAsset(180091587).Parent = game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui

Please note that I will be using it in this working script.

Access = {"KeepOnBuilding","Phirexx"}

function checkOkToLetIn(name) 
	for i = 1,#Access do 
		if (string.upper(name) == string.upper(Access[i])) then return true end 
	end 
	return false 
end 

local Door = script.Parent
function onTouched(hit) 
	print("Door Hit") 
	local human = hit.Parent:findFirstChild("Humanoid") 
	if (human ~= nil ) then 
		print("Human touched door") 
		if (checkOkToLetIn(human.Parent.Name)) then 
			print("Human passed test") 
			Door.SurfaceGui.W.Visible = false
			Door.SurfaceGui.A.Visible = true
                       (Script to insert goes here)
			wait(3)
			Door.SurfaceGui.A.Visible = false
			Door.SurfaceGui.W.Visible = true
		else 
			Door.SurfaceGui.W.Visible = false
			Door.SurfaceGui.D.Visible = true
			wait(3)
			Door.SurfaceGui.D.Visible = false
			Door.SurfaceGui.W.Visible = true
		end 
	end 
end 

script.Parent.Touched:connect(onTouched)

1 comment

0

Please edit your Question to include additional info in the future, don't Answer your Question with it.

That game.Players.localplayer.PlayerGui.InsertInstance:(180091578) you said did not work? Actually localplayer is supposed to be LocalPlayer.

If it helps then Congrats :D

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