script.Parent (function(hit)
game.StarterGui.ScreenGui.GoodJob.Visible = true
wait(10)
game.StarterGui.ScreenGui.GoodJob.Visible = false
end)
✓ ANSWER ACCEPTED
How do I make a GUI show when a block is touched?
2 answers
✓ Accepted answer
Your issue is that you're attempting to change the object located in StarterGui. When a player loads into a game, the contents of this service are cloned into a folder in the player called PlayerGui. Thus, you want to change the objects in that folder. The problem is that you cannot access existing members of PlayerGui through the server, so we're going to have to use a Remote Event.
--Server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = Instance.new("RemoteEvent") --create remote
RemoteEvent.Parent = ReplicatedStorage
local part = workspace.Part
part.Touched:Connect(function(otherPart)
local player = game:GetService("Players"):GetPlayerFromCharacter(otherPart.Parent)
if player then --ensure existence
RemoteEvent:FireClient(player,"") --any data can be sent through the second argument
end
end)
--Local script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent") --wait for remote
local player = game:GetService("Players").LocalPlayer
RemoteEvent.OnClientEvent:Connect(function(args) --the data you sent
local Gui = player.PlayerGui:FindFirstChild("ScreenGui")
if Gui then --ensure existence
Gui.GoodJob.Visible = true
wait(10)
Gui.GoodJob.Visible = false
end
end)
##Resources:
:GetPlayerFromCharacter()
##Accept and upvote if this helps!
local part = game.Workspace.Part
part.Touched:Connect(function(hit)
if hit.Parent.Humanoid then
local screengui = script.Parent.Parent
screengui.Enabled = true
end
end)
game.StarterGui.ScreenGui.TextLabel.LocalScript
Make sure you do it in the order above
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
local part = game.Workspace.Part part.Touched:Connect(function(hit) if hit.Parent.Humanoid then local screengui = script.Parent screengui.Enabled = true end end)