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

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.

3 comments

0

Could you explain more in detail what is happening? Is it working or not? Does the gui pop up or not?

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.

0

Should i use the StarterGui as its class name?

2 answers

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

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)

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