I need help with a script

Could someone please help me figure out why this script doesn’t work. It was working earlier but it showed up for everyone in the game (It was in a local script), and now the output doesn’t give me any errors.

script.Parent.Parent.Touched:Connect(function()
game.StarterGui["Item/RebirthShop"].Enabled = true
game.StarterGui["Item/RebirthShop"].Frame.Visible = true
end)

Thank You

You wan’t to use, player.PlayerGui instead. When a player joins, everything from the StarterGui is cloned into their PlayerGui, what they see is their PlayerGui, not the StarterGui


script.Parent.Parent.Touched:Connect(function(hit)
     local player = game.Players:GetPlayerFromCharacter(hit.Parent) --get the player from the part that touched it
     if player then
        player.PlayerGui["Item/RebirthShop"].Enabled = true
        player.PlayerGui["Item/RebirthShop"].Frame.Visible = true
     end
end)
3 Likes

You need to get the player from the touched function and then do player.PlayerGUI instead. Use @XdJackyboiiXd21’s solution.

Hi!

The problem is that you are trying to change the game’s StarterGui instead of the PlayerGui. If you use:
player.StarterGui[Item/RebirthShop].Enabled = true
It will work.

Hopefully this helped you! :smiley:

Thank you, @XdJackyboiiXd21, @starrydarkn3ss and @DoudGeorges

I will try all your solutions and tell you if it works :slightly_smiling_face:

1 Like
-- services
local players = game:GetService("Players")

-- Functions
script.Parent.Touched:Connect(function(hit)
     local player = players:GetPlayerFromCharacter(hit.Parent)
     if player then
         if player.PlayerGui:FindFirstChild("Item/RebirthShop") then
             player.PlayerGui["Item/RebirthShop"].Enabled = true
             player.PlayerGui["Item/RebirthShop"].Frame.Visible = true
         end
     end
end)
1 Like

Thank You,

@Revitic, @DoudGeorges, @starrydarkn3ss and @XdJackyboiiXd21

But a solution has been found

1 Like

You should probably include the solution in your post that you marked as a solution for people who read this to see what it is that you did to make it work.