I try to play the part that shows a GUI and it doesn’t work. Who can help me, please?
game.Workspace.Lol.Touched:connect(function(hit)
local Open = game.StarterGui.BuyZoneUnderwater.Hijo
if hit.Parent:FindFirstChildWhichIsA('Humanoid') then
Open.Visible = true
end
end
StarterGui is a replicated service. So I don’t recommend setting a Gui variable by StarterGui, I recommend it by PlayerGui.
So, you have to do this in a LocalScript, and type in the following:
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
game.Workspace.Lol.Touched:Connect(function(hit)
local Open = PlayerGui.BuyZoneUnderwater:WaitForChild("Hijo")
if hit.Parent:FindFirstChildWhichIsA('Humanoid') then
Open.Visible = true
end
end
local Player = game.Players.LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local function onTouched(hit)
local Open = PlayerGui.BuyZoneUnderwater:WaitForChild("Hijo")
if hit.Parent:FindFirstChildWhichIsA('Humanoid') then
Open.Visible = true
end
game.Workspace.Lol.Touched:Connect(onTouched)
workspace.Lol.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild('HumanoidRootPart') ~= nil then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
player:WaitForChild('PlayerGui').BuyZoneUnderwater.Hijo.Visible = true
end
end