When touching a part... how to make a ScreenGui "pop up" then disappear after 1 second?

Hello, I am trying to make +1 show up with a local script when touching a part. So far I tried enabling and disabling the ScreenGui. Ive tried making the TextLabel visible to not visible. (they start off disabled/not visible.)

I have the local script inside the part for future easy copy/paste for different parts instead of making new ScreenGuis over and over again.

Here is the script I am currently trying to use

---- Local Script inside the Berry part ---

local ScreenGui = game.Players.LocalPlayer.PlayerGui:WaitForChild("ScreenGui") -- Screen that is being turned on and off
local oneRedBerry = game.Workspace.oneRedBerry -- Berry that is being collected

oneRedBerry.Touched:Connect(function(hit) -- Touching Berry
	local Humanoid = hit.Parent:FindFirstChild("Humanoid") -- Find Humanoid
		if Humanoid then
			local Player = game.Players:GetPlayerFromCharacter(hit.Parent) -- Find Player
				if Player then
					wait(0.5)				  -- Wait till ScreenGui "Pops Up"
					ScreenGui.Enabled = true
					wait(1)
					ScreenGui.Enabled = false
end
end
end)
2 Likes

Like this?

1 Like

Hey em im not sure you knew this, but local scripts cannot go in workspace, and do not work.

2 Likes
script.Parent.Touched:Connect(function(hit)
    		if hit.Parent:FindFirstChild("Humanoid") then
    				if game.Players:FindFirstChild(hit.Parent.Name) then
    					wait(0.5)
    					game.Players:FindFirstChild(hit.Parent.Name).ScreenGui.Enabled = true
    					wait(1)
    					game.Players:FindFirstChild(hit.Parent.Name).ScreenGui.Enabled = false
    end
    end
    end)

This should work :slight_smile: just remember you cannot get the LocalPlayer if it is not a localscript, and localscripts cannot go in workspace, because you need one for each player.

1 Like

I skimmed through the video really quick and yeah, something very similar to that! Thank you for posting this video.

1 Like

Hey I am not sure if you knew this, but you can’t access playergui with normal script. About the solution, he gets all players that touch that part, he should check if that player is local player and make gui pop up (his script didn’t work because you can’t access other people’s playergui aswell and it should be in playerscripts,startergui or other containers that serve that role.

1 Like

Huh? I dont understand what you’re talking about, and yes you can access playergui with a normal script, i use it all the time for my saving and loading script or other scripts. So maybe search stuff up?

@LukeBLOXDaily So the code you gave me, is it supposed to be in a server script instead of a local script? Also Ive tried putting my original script inside the ScreenGui which is inside the StarterGui and the gui still doesnt pop up. Imma keep fidgeting

Eh keep it where it is, simply change the code in script. Im not sure but i think you said the script is in block (berry) you touch. If so the script should work perfectly

Nothing in playergui replicate to server, you can only change it if you cloned it from server then change it within that script.

1 Like

Oh hang on yes im sorry i didnt understand correctly, you must put it in a normal script inside the part you want to touch for it to work.

Sorry i think you have it wrong. You cannot access any PlayerGui’s appart from your own in a localscript, in server scripts you can acess everything in the game.

In case you still don’t understand you can look at @Maximum_ADHD 's reply on this post as I don’t want to search it in roblox docs
Source: Accessing PlayerGui in FE

1 Like

Oh and deathful one more thing, you shouldnt do this:

local Humanoid = hit.Parent:FindFirstChild("Humanoid") -- Find Humanoid
if Humanoid then

if you do and there is no humanoid, then it will give you an error:

Humanoid is not a valid object of model -- The error will look a bit like this

instead you should do this:

if hit.Parent:FindFirstChild("Humanoid") then
local Humanoid = hit.Parent:FindFirstChild("Humanoid")

I have filtering enabled on, use server scripts and access PlayerGui’s for every player that joins and exists so.?
And even mid game

I don’t know what else I could do, if you don’t know that it doesn’t replicate to server (common sense) and don’t want to look at top developers posts to understand there is not much left.

1 Like

What top developpers do does not concern me, my scripts work using everything he needs so im simply giving him the same type of script, if it does not work there is another simple way to do it but hey it works for me i dont know why it wouldnt work for ANYONE else in the entire world, and that isn’t really my problem. Anyways im jsut trying to help him if it does not work he can tell me since it should work from personal experience.

And btw it is the client that is replicated from server, any changes made inside client will not be made inside server, but changes made inside server will be made inside client.

You just got yourself, “any change from client is not replicated to the server”. Gui is purely clientsided and does not replicate to server.

1 Like

Lol dude. If you change a gui transparency form client, it wont change in server, PlayerGui is still accessible from server to any clients PlayerGui. Please just stop arguing on this dumb conversation. Ill fix it myself if it does not work. I always change gui’s inside server that way if i need to access them from another player, like i need to in my game, i can easily without having the wrong information.