0

# What's wrong with this script?? no error message. (I am a beginner)

Here's The Script:

script.Parent.TouchPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
game.GUIS.GamepassShop.ShopFrame.Visible = true
game.Workspace.Map.Parts.MainBase.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
game.GUIS.GamepassShop.ShopFrame.Visible = false
game.Workspace.Map.Parts.SideWalk2.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
game.GUIS.GamepassShop.ShopFrame.Visible = false
end
end)
end
end)
end
end)


There is no error message I don't understand what is wrong. I am a beginner scripter.

0
Could you explain more in detail what is happening? Is it working or not? Does the gui pop up or not? FireTap1 12 — 2mo
0
If you use Game.StarterGui and make changes there, they only take effect when a player spawns his character again. Each GUI is put in Player.PlayerGui separately for each player. Bankrovers 226 — 2mo
0
Should i use the StarterGui as its class name? TheKittyKingOfficial 2 — 2mo

0

Try printing something in between lines and then checking at what line the script stops running. If the script runs through all the lines. Then it could be because your using .Touched event for opening a GUI. I would recommend using/learning Region3 because .Touched runs every time your leg / bodyPart touches the Part causing it to open and close really fast - Region3 will keep waiting until a player enters the area and will open it once

0

You used the wrong identification for your GUIs. Correct code should look something like this:

script.Parent.Touched:Connect(function(hit)

if hit.Parent:FindFirstChildOfClass("Humanoid") then
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
p.PlayerGui.GamepassShop.ShopFrame.Visible = true
end
end
end)

game.Workspace.Map.Parts.SideWalk2.Touched:Connect(function(hit)

if hit.Parent:FindFirstChildOfClass("Humanoid") then
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
p.PlayerGui.GamepassShop.ShopFrame.Visible = false
end
end
end)