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.
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)
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.
-- 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)
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.