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

How do I access the PlayerGui from a part in Workspace?

This LocalScript is supposed to change some values in PlayerGui when a ClickDetector is clicked.

function questComplete(player)
	if player.PlayerGui.PlayerQuests.InceptionTime.InProgress.Value == true then
		player.PlayerGui.PlayerQuests.InceptionTime.InProgress.Value = false
		player.PlayerGui.PlayerQuests.InceptionTime.Complete = true
		player.PlayerGui.Quests.QuestList.List.InceptionTime.InProgress.Visible = false
		player.PlayerGui.Quests.QuestList.List.InceptionTime.Complete.Visible = true
	elseif player.PlayerGui.PlayerQuests.InceptionTime.Complete.Value == true then
		player.PlayerGui.Quests.AlreadyComplete.Visible = true
			wait(5)
		player.PlayerGui.Quests.AlreadyComplete.Visible = false
	end
end

script.Parent.MouseClick:connect(questComplete)

Thank you in advance for any help you may provide :)

1 comment

1

Since its a localscript, you could just use game.Players.LocalPlayer [If you have FE on that is]. If you dont have FE on, just replace player with game.Players.LocalPlayer but instead add "if player ~= game.Players.LocalPlayer then return end" to the beginning.

1 answer

✓ Accepted answer

Because its hard to understand from a comment, try looking at this:

function questComplete(plr)
  local player = game.Players.LocalPlayer
  if plr ~= player then return end
    if player.PlayerGui.PlayerQuests.InceptionTime.InProgress.Value == true then
        player.PlayerGui.PlayerQuests.InceptionTime.InProgress.Value = false
        player.PlayerGui.PlayerQuests.InceptionTime.Complete = true
        player.PlayerGui.Quests.QuestList.List.InceptionTime.InProgress.Visible = false
        player.PlayerGui.Quests.QuestList.List.InceptionTime.Complete.Visible = true
    elseif player.PlayerGui.PlayerQuests.InceptionTime.Complete.Value == true then
        player.PlayerGui.Quests.AlreadyComplete.Visible = true
            wait(5)
        player.PlayerGui.Quests.AlreadyComplete.Visible = false
    end
end

script.Parent.MouseClick:connect(questComplete)

Since your using a localscript, you can access the local player through game.Players.LocalPlayer

I also added the if plr ~= player then return end to ensure that it doesn't change when someone else touches the block.

Hopefully this clears it for you.

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