Why is my gui script not working?

  1. What am I trying to do? I’m trying to make a gui text
    Change when Proximity Prompt is triggered

  2. What is the issue? The gui text is not changing

  3. Thing’s i’ve tried I tried searching it up, and I tried making the script a local script

Here is my script

local int = game.Workspace.Int
local  pp = script.Parent
local anim = script.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Parent.Animation)
pp.Triggered:Connect(function()
	if game.StarterGui.ScreenGui.Me.Text == "Label" then
		game.StarterGui.ScreenGui.Me.Text = "Me:Hey Detective have you found anything yet?"
	end
	wait(5)
	if game.StarterGui.ScreenGui.Me.Text == "Me:Hey Detective have you found anything yet?" then
		game.StarterGui.ScreenGui.Me.Text = "Detective: No I haven't found anything yet!"
		anim:Play()
	end	
end)
	
	
	
1 Like

You’re changing from StarterGui, the changes wont replicate until a respawn happens, you need to reference the player’s PlayerGui, which thankfully is possible since Triggered returns the Player who triggered the event, try this out

local int = game.Workspace.Int
local  pp = script.Parent
local anim = script.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Parent.Animation)

pp.Triggered:Connect(function(plr)
	local plrGui = plr.PlayerGui
	if plrGui.ScreenGui.Me.Text == "Label" then
		plrGui.ScreenGui.Me.Text = "Me:Hey Detective have you found anything yet?"
	end
	wait(5)
	if plrGui.ScreenGui.Me.Text == "Me:Hey Detective have you found anything yet?" then
		plrGui.ScreenGui.Me.Text = "Detective: No I haven't found anything yet!"
		anim:Play()
	end	
end)
2 Likes

Thank you so much! It works now

1 Like

Anytime! If you have anymore issues don’t be afraid to make another post!

Nevermind, you have fixed the problem.