The Script isnt making these parts nvisble

The local script is supposed to make the following part invisible but it isnt working
heres the local script:

local Cheese = game.Workspace.LevelOne.Cheese
local Meat = game.Workspace.LevelOne.Meat
local Buns = game.Workspace.LevelOne.Buns
local arrow = game.Workspace.LevelOne.Model.Touch
local text = script.Parent
local players = game:GetService("Players")
local level = players.LocalPlayer:WaitForChild("Level")
local gold = players.LocalPlayer:WaitForChild("Gold")
local textvalue = 0
local ingredients = 0
local function UpdateText()
	textvalue += 1
	if level.Value == "Tutorial" then
		text.Text = textvalue.. " /  3 Find Cheese, Meat, and Buns"

	elseif level.Value == "LevelOne" then 
		text.Text = textvalue.. " /  3"
	end

end

if level.Value == "LevelOne" then

	Cheese.Touched:Connect(function()
	print("touched")
	UpdateText()
	Cheese.Transparency = 1
	Cheese.CanTouch = false
	ingredients += 1
	if ingredients == 3 then
		text.Text = "You got the Ingredients, Now go to the house"
		text.TextSize = 20
		arrow.BillboardGui.ImageLabel.Visible = true
	end
end)
	Meat.Touched:Connect(function()
		print("touched")
		UpdateText()
		Meat.Transparency = 1
		Meat.CanTouch = false
		ingredients += 1
		if ingredients == 3 then
			text.Text = "You got the Ingredients, Now go to the house"
			text.TextSize = 20
			arrow.BillboardGui.ImageLabel.Visible = true
		end
	end)
	Buns.Touched:Connect(function()
		print("touched")
		UpdateText()
		Buns.Transparency = 1
		Buns.CanTouch = false
		ingredients += 1
		if ingredients == 3 then
			text.Text = "You got the Ingredients, Now go to the house"
			text.TextSize = 20
			arrow.BillboardGui.ImageLabel.Visible = true
		end
	end)
	arrow.Touched:Connect(function()
		if ingredients == 3 then
			script.Parent.Parent.Parent.Parent.Parent.Special.YouWon:TweenPosition(UDim2.new(0.256,0,0.143,0), "Out", "Quad",1,true)
			script.Parent.Parent.Parent:TweenPosition(UDim2.new(0.236,0,800,0), "Out", "Quad",1,true)
			textvalue = 0
			ingredients = 0
			text.TextSize = 50
			arrow.BillboardGui.ImageLabel.Visible = false
			if level.Value == "Tutorial" then
				script.Parent.Parent.Parent.Parent.Parent.Special.YouWon.Frame.Coins.Text = "Coins : 15"

			end
		end
	end)
end
1 Like

Try using more print statements to see where the script is working and where it’s not.
Do you get any error messages in the Output window?

No I didn’t see any errors in the output, but I will try to use the print statements

None of the print statements appeared in the output.

if level.Value == "LevelOne" then

end

try putting a print there, maybe the script detects that the current level is not “LevelOne” so it ends and abandons the entire if statement never to be used again

Yes, it didn’t print the statement, but in one of my local scripts it changes the value of level to “LevelOne”’
here is the local script:

local player = game:GetService("Players")
local level = player.LocalPlayer:WaitForChild("Level")

script.Parent.MouseButton1Up:Connect(function()
	level.Value = "LevelOne"
	script.Parent.Parent.Parent.Parent.Areyousure.Visible = true
end)

instead of running the “if” statement outside of the touched events, why dont you just put it in the touched events themselves?

2 Likes