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

Is there an error with my conditionals to make a GUI visible?

local Part = game.Workspace.MediterraneanAvenue
 local function playerHasTool(player, toolName)
        local tool = player.Backpack:FindFirstChild(toolName) or player.Character:FindFirstChild(toolName)
     if tool then
            return true
        else
            return false
        end
    end
     
local Player
        Part.Touched:Connect(function(HIT)
        Player = game.Players:GetPlayerFromCharacter(HIT.Parent)
        local H  = HIT.Parent:FindFirstChild("Humanoid")
     
        if H and not game.ReplicatedStorage:FindFirstChild("MediterraneanAvenue") and not playerHasTool(Player,"MediterraneanAvenue") then
    print("Conditional recognized.")
    script.Parent.Visible = true
    
end
end)

This is my script. So I want a GUI to appear if a tool isn't found with a player or in replicated storage. Why isn't the gui appearing? Is there an error with my conditionals? Please help me!

1 comment

0

How many parents are there supposed to be

1 answer

So I checked your code and saw some POSSIBLE error, Forgetting to call your function (This may be wrong but try calling as shown down below), also if you want the GUI to appear only when the brick is touched then put the function called inside the > Part.Touched Event

local Part = game.Workspace.MediterraneanAvenue
 local function playerHasTool(player, toolName)
     local tool = player.Backpack:FindFirstChild(toolName) or player.Character:FindFirstChild(toolName)
     if tool then
         return true
        else
         return false
     end
 end

playerHasTool()
local Player
Part.Touched:Connect(function(HIT)
 Player = game.Players:GetPlayerFromCharacter(HIT.Parent)
 local H  = HIT.Parent:FindFirstChild("Humanoid")

 if H and not game.ReplicatedStorage:FindFirstChild("MediterraneanAvenue") and not playerHasTool(Player,"MediterraneanAvenue") then
 	print("Conditional recognized.")
    script.Parent.Visible = true
 end
end)

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