Problem making a tycoon game

Im attempting to make a tycoon type of game and I am struggling to make the buttons. It is a Server Script in ServerScriptService. Everything works, accept this part of the code:

						if Object.Value then
							Object.Value.Transparency = 0
							Object.Value.CanCollide = true
							task.wait(.1)
							if Object.Value == "Window" then
								Object.Value.Transparency = 0.8
							end
						end

It ignores the if statement

								Object.Value.Transparency = 0.8
							end

I have tried making it parent to a certain folder in workspace with the properties already done, all it does is make the transparency 1. I’ve tried seperate If statements, nothings worked.

full code:

local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local ServerStorage = game:GetService("ServerStorage")
local SoundService = game:GetService("SoundService")

local Buttons = game.Workspace:WaitForChild("Buttons")
local Tycoon = game.Workspace:WaitForChild("Tycoon")
local Sounds = SoundService:WaitForChild("Sounds")

local ErrorSound = Sounds.ErrorSound
local MoneySound = Sounds.MoneySound

local Debounce = false

for i,v in pairs(Buttons:GetChildren()) do
	if v:FindFirstChild("Button") then
		v.ButtonInfo.PriceText.Text = tostring("$"..v.Price.Value)
		v.Button.Touched:Connect(function(Hit)
			local Character = Hit.Parent
			if Character:FindFirstChild("Humanoid") then
				if not Debounce then
					Debounce = true
					v.Button.Position = v.Button.Position + Vector3.new(0, -.25, 0)
					task.wait(.5)
					v.Button.Position = v.Button.Position + Vector3.new(0, .25, 0)
					local Player = Players:GetPlayerFromCharacter(Character)
					local leaderstats = Player:WaitForChild("leaderstats")
					local PlayerGui = Player.PlayerGui
					if leaderstats.Money.Value >= v.Price.Value then
						leaderstats.Money.Value -= v.Price.Value
						MoneySound:Play()
						v.Button.Color = Color3.fromRGB(0, 255, 0)
						task.wait(.5)
						local Tween1 = TweenService:Create(v.Button, TweenInfo.new(.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {Transparency = 1}):Play()
						local Tween2 = TweenService:Create(v.ButtonBase, TweenInfo.new(.5, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, 0), {Transparency = 1}):Play()
						v.ButtonInfo.Enabled = false
						task.wait(1)
						local Object = v:WaitForChild("Object")
						local NextButton = v:WaitForChild("NextButton")
						if Object.Value then
							Object.Value.Transparency = 0
							Object.Value.CanCollide = true
							task.wait(.1)
							if Object.Value == "Window" then
								Object.Value.Transparency = 0.8
							end
						end
						if NextButton.Value then
							for i,v in pairs(NextButton.Value:GetChildren()) do
								if v:IsA("MeshPart") then
									v.Transparency = 0
									if v.Transparency == 0 then
										v.Parent.ButtonInfo.Enabled = true
									elseif not NextButton.Value then
										PlayerGui.ErrorGui.ErrorText.Visible = true
										PlayerGui.ErrorGui.ErrorText.Text = "That was the last button!"
									end
								end
							end
						end
						v:Destroy()
						task.wait(2)
						Debounce = false
					elseif leaderstats.Money.Value <= v.Price.Value then
						PlayerGui:WaitForChild("ErrorGui").ErrorText.Visible = true
						PlayerGui:WaitForChild("ErrorGui").ErrorText.Text = "Not enough money!"
						ErrorSound:Play()
						task.wait(1)
						PlayerGui:WaitForChild("ErrorGui").ErrorText.Visible = false
						PlayerGui:WaitForChild("ErrorGui").ErrorText.Text = "Label"
					end
				end
			end
		end)
	end
end

Any help is appreciated!

Do you mean to check the Name property? Assuming it’s an Instance because you set a Transparency property right after.

1 Like

Yeah so basically I want to check If the Object.Value is = to “Window” which is a part inside a Folder named Tycoon, then it sets Windows Transparency to 0.8

Yes, so you want to change that line to if Object.Value.Name == "Window" then

1 Like

Wow lol that worked. Thanks and sorry for wasting your time… this is my first time using ObjectValues and it was kinda confusing me so I may have been thinking a little too hard.

1 Like

Don’t worry, there’s no time to waste if I’m on the DevForum, lol.

1 Like