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

Access PlayerGui from a normal script?

So. How do i turn this script into so i can load the playergui with a normal gui i dont wanna load a playername i just wanna load a gui if you touch a brick and that script dosent work with a localscript so i would need some help with this.

Here's the current script.

local debounce = false
 
function Shop(hit)
    if not debounce then
        if hit.Parent:FindFirstChild("Humanoid") then
			if game.Players.PlayerGui.Job.JobActive == false then
            local clone = game.ServerStorage.JobGuis:FindFirstChild("CableMan"):Clone()
            clone.Parent = game.Players:FindFirstChild(hit.Parent.Name).PlayerGui
            debounce = true
            wait(5)
            debounce = false
			end
        end
    end
end
 
script.Parent.Touched:connect(Shop)

2 comments

0

Use a remote event to edit the gui

0

i dont know how to use remote events.

1 answer

I made a whole new script.

Step 1. Pay attention, read the lines correctly. Step 2. Put a "StringValue" into the brick. It should look like this:

http://prntscr.com/c7tusu

Step 3. Paste the script into the part. Step 4. Put the gui into ReplicatedStorage!

local button = script.Parent

script.Parent.Touched:connect(function(part) --Brick's touched by character.
	if part.Parent:FindFirstChild("Humanoid") ~= nil then --if humanoid exists.
		local player = game.Players:GetPlayerFromCharacter(part.Parent) -- get player from character.
		if player ~= nil then --if the player exists.
			local GUI = game.ReplicatedStorage:FindFirstChild(script.Parent.ShopGUI.Value) -- get the gui's name from the ShopGUI.Value.
			local AlreadyHaveGUI = player.PlayerGui:FindFirstChild(script.Parent.ShopGUI.Value)-- check if the player has the gui
			if AlreadyHaveGUI == nil then --if he doesn't have it
			GUI:Clone().Parent = player.PlayerGui --then we clone the gui!
			else print("Already have GUI!")
			end
		end
	else print("Humanoid not found!")
	end
end)

If i helped, please accept the answer button!

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