this is my script:
~~~~~~~~~~~~~~~~~
local Part = script.Parent
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
Part.Touched:Connect(function(HIT)
local Player = game.Players:GetPlayerFromCharacter(HIT.Parent)
local H = HIT.Parent:FindFirstChild("Humanoid")
if H and not playerHasTool(Player,"MediterraneanAvenue") then
Player.PlayerGui.MediterraneanAvenue.StartUp.Visible = true
end
if H and playerHasTool(Player,"MediterraneanAvenue") and not playerHasTool(Player,"BalticAvenue") then
Player.PlayerGui.MediterraneanAvenue.NeedToOwnAll.Visible = true
end
if H and playerHasTool(Player,"MediterraneanAvenue") and playerHasTool(Player,"BalticAvenue") then
Player.PlayerGui.MediterraneanAvenue.ClickBuild.Visible = true
end
end)
Part.TouchEnded:Connect(function(part) -- leaves the part
if game.Players:GetPlayerFromCharacter(part.Parent) then -- if the part leaving is a player
local Player = game.Players:GetPlayerFromCharacter(part.Parent) -- the player
if Player.PlayerGui.MediterraneanAvenue.StartUp.Visible == true then -- if the gui is open
Player.PlayerGui.MediterraneanAvenue.StartUp.Visible = false
if Player.PlayerGui.MediterraneanAvenue.NeedToOwnAll.Visible == true then
Player.PlayerGui.MediterraneanAvenue.NeedToOwnAll.Visible = false
if Player.PlayerGui.MediterraneanAvenue.ClickBuild.Visible == true then
Player.PlayerGui.MediterraneanAvenue.ClickBuild.Visible = false
end
end
end
end
end)
It is for making GUI visible when a player touches a part, if he has some tools in his backpack.
it is NOT A LOCAL SCRIPT but a normal script that is inside the part which has to be touched. However, when the part is touched, the GUI doesn't appear.
Can I know why?
Can someone pleeeeeasssssseeee help me?
