Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
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!

0
How many parents are there supposed to be DuckyRobIox 280 — 4y

1 answer

Log in to vote
0
Answered by
vChuys 0
4 years ago

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

Answer this question