How To MAKE A Tycoon Game in Roblox Studio | Part 5 - Buttons!

How To MAKE A Tycoon Game in Roblox Studio | Part 5 - Buttons!

Rustysillyband

1 год назад

37,329 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@rustysillyband
@rustysillyband - 04.06.2023 05:37

Please make sure you do not put spaces in the names of your items inside your Purchased Items folder.

Main Script:

local buttons = tycoon:FindFirstChild("Buttons")
local purchasedItems = tycoon:FindFirstChild("PurchasedItems")

local objects = {}

if buttons then
for i, v in pairs(buttons:GetChildren()) do
spawn(function()
if v:FindFirstChild("Button") then

local newObject = purchasedItems:FindFirstChild(v.Object.Value)
if newObject ~= nil then
objects[newObject.Name] = newObject:Clone()
newObject:Destroy()
else
v:Destroy()
end

if v:FindFirstChild("Dependency") then
v.Button.Transparency = 1
v.Button.CanCollide = false
v.Button.BillboardGui.Enabled = false
coroutine.resume(coroutine.create(function()
if purchasedItems:WaitForChild(v.Dependency.Value) then
v.Button.Transparency = 0
v.Button.CanCollide = true
v.Button.BillboardGui.Enabled = true
end
end))
end

v.Button.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
if values.OwnerValue.Value == player then
if v.Button.CanCollide == true then
if player:FindFirstChild("leaderstats").Cash.Value >= v.Price.Value then
player.leaderstats.Cash.Value -= v.Price.Value
objects[v.Object.Value].Parent = purchasedItems
v:Destroy()
end
end
end
end
end)
end
end)
end
end


Script inside of buttons:

local ownerValue = script.Parent.Parent.Parent.Parent.Values.OwnerValue

ownerValue.Changed:Connect(function()
if ownerValue.Value then
local player = ownerValue.Value
while wait(0.1) do
if player:FindFirstChild("leaderstats").Cash.Value >= script.Parent.Parent.Price.Value then
script.Parent.BrickColor = BrickColor.new("Lime green")
else
script.Parent.BrickColor = BrickColor.new("Really red")
end
end
end
end)

Ответить
@Alisita_
@Alisita_ - 04.02.2024 11:14

i got an error: Button is not a valid member of Model "DropperButton" - Server - Core:37
then the buttons just desapeared...

Ответить
@Sup3rDr4k3
@Sup3rDr4k3 - 04.02.2024 03:27

Hello, I'm having a small hiccup in my code and I would like to know if there is anybody who could help me! It would mean a lot, thank you.

My main problem I'm having is: the first dropper button appears, but when stepping upon it, the dropper also appears. But then, the colorizer button doesn't show up, and I don't think the colorizer would even show up in the workspace.

If anyone needs my code pasted or anything, I will gladly paste it here.

Ответить
@BlinxOnFn
@BlinxOnFn - 02.02.2024 05:52

For me i have an error Button is not a valid member of Model "DropperButton" - Server - Core:50 in the second button, because of the error the button doesnt show up

Ответить
@InspectingGadget
@InspectingGadget - 02.02.2024 03:14

Having trouble again, when I step on the first button, it works but the second one doesn’t appear.

Ответить
@connorisyt6660
@connorisyt6660 - 31.01.2024 00:34

why is it when i start the game the colorizer button shows before i touched the dropper button?

Ответить
@Epreteszem_YT
@Epreteszem_YT - 30.01.2024 13:03

Dosent duplicate the button dosent change color 😢

Ответить
@trevormcglothan
@trevormcglothan - 30.01.2024 04:46

I don’t know what I did wrong but every time I touch the Dropper 1 button it says that Workspace.Tycoons.Tycoon.Script.core:55: attempt to index nil with ‘Cash’ can someone help me please.

Ответить
@beebold9916
@beebold9916 - 29.01.2024 00:53

Im not sure where i went wrong but the second button doesnt turn green even when the CashValue inside my tycoon reaches above the amount i set it to

Ответить
@sarthakjagtap7889
@sarthakjagtap7889 - 28.01.2024 07:15

Thanks bro

Ответить
@TheHobbyKid1
@TheHobbyKid1 - 21.01.2024 03:05

can you have 2 different parts on a button? a base and the button

Ответить
@YT_weakyunus
@YT_weakyunus - 20.01.2024 20:20

Is The part where u need to make the material and colourchanger nececerrely for this Episode?

Ответить
@user-jg5ro4xu4h
@user-jg5ro4xu4h - 15.01.2024 13:34

Core Script:

local tycoon = script.Parent.Parent

local mainItems = tycoon:FindFirstChild("MainItems")
local values = tycoon:FindFirstChild("Values")

local buttons = tycoon:FindFirstChild("Buttons")
local purchasedItems = tycoon:FindFirstChild("PurchasedItems")

local objects = {}

mainItems.OwnerDoor.Door.Touched:Connect(function(hit)
if values.OwnerValue.Value == nil then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
if player:FindFirstChild("HasTycoon").Value == false then
values.OwnerValue.Value = player
mainItems.OwnerDoor.Title.SurfaceGui.TextLabel.Text = tostring(values.OwnerValue.Value).."'s Tycoon"
end
end
end
end)


if buttons then
for i, v in pairs(buttons:GetChildren()) do
spawn(function()
if v:FindFirstChild("Button") then

local newObject = purchasedItems:FindFirstChild(v.Object.Value)
if newObject ~= nil then
objects[newObject.Name] = newObject:Clone()
newObject:Destroy()
else
v:Destroy()
end

if v:FindFirstChild("Dependency") then
v.Button.Transparency = 1
v.Button.CanCollide = false
v.Button.BillboardGui.Enabled = false
coroutine.resume(coroutine.create(function()
if purchasedItems:WaitForChild(v.Dependency.Value) then
v.Button.Transparency = 0
v.Button.CanCollide = true
v.Button.BillboardGui.Enabled = true
end
end))
end

v.Button.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
if values.OwnerValue.Value == player then
if v.Button.CanCollide == true then
if player:FindFirstChild("leaderstats").Cash.Value >= v.Price.Value then
player.leaderstats.Cash.Value -= v.Price.Value
objects[v.Object.Value].Parent = purchasedItems
v:Destroy()
end
end
end
end
end)
end
end)
end
end

Ответить
@emilmatasareanuuu
@emilmatasareanuuu - 15.01.2024 12:51

Okay, so basically I found out where my error was coming from. It was after we checked to see if newObject was nil or not (when we destroy v after the else), and I'm not too sure why its throwing me this error.

Ответить
@Sumde
@Sumde - 12.01.2024 14:35

Infinite yield possible on 'Workspace.Tycoons.Tycoon.PurchasedItems:WaitForChild("Dropper")'

????

Ответить
@user-pb6if9qz5r
@user-pb6if9qz5r - 09.01.2024 21:44

Please help me, he writes an error - Workspace.Tycoons.Tycoon.Scripts.Core:29: attempt to index nil with 'FindFirstChild'

Ответить
@FireCobra
@FireCobra - 09.01.2024 00:37

i get an error infinite yield possible for dropper?

Ответить
@iosifplays12344
@iosifplays12344 - 05.01.2024 00:00

hey i have a problem with my buttons the colorizer button dosent dissapear and it dosent work when i try to buy it even if i have the right amount of money can you help me ?

Ответить
@Bacon_905
@Bacon_905 - 04.01.2024 07:52

i get the error message "Object is not a valid member of Model "DropperButton" - Server - Core:181" and i did everything in the vid how can I fix it?

Ответить
@Bacon_905
@Bacon_905 - 04.01.2024 07:19

I get the error message "exception while signaling: Must be a LuaSourceContainer - Studio" after buying my first dropper and the one i cant afford isnt red its just white even tho i copied it so it'd be red

Ответить
@Bacon_905
@Bacon_905 - 04.01.2024 04:29

it says "Cash is not a valid member of Folder "Players.Ninjaboygg1.leaderstats"
how do i fix?

Ответить
@lucaKSP
@lucaKSP - 31.12.2023 03:04

Hey there! Dont know if im a bit late, but when making a new button it works perfectly fine, yet when it gets touched once, it removes the cash, and if you like walk over it it detects multiple touches, so it takes the price away from you multiple times. the cooldown (while wait do) doesnt help at all in this case.

Ответить
@Ban33t
@Ban33t - 29.12.2023 04:16

Whenever you step on button for too long, (or walk on it) since the button destroys after it takes away the cash, it takes away more money then always. It quickly runs out. Any fixes? This affects the game so much as the player will spend more money unknowingly.

Ответить
@SudSabYT
@SudSabYT - 28.12.2023 15:18

There is an error that i tried to fix but i couldnt . The error in the output says : Button is not a valid member of Model "ColorizerButton"

Ответить
@sour_axolotl
@sour_axolotl - 28.12.2023 14:14

The tutorial was great but I have some issues :P
It said : Infinite yield possible on 'Workspace.Tycoons.Tycoon.PurchasedItems:WaitForChild("Dropper")'
Which I don't understand what it means

here's the script :

local tycoon = script.Parent.Parent

local mainItems = tycoon:WaitForChild("MainItems")
local values = tycoon:WaitForChild("Values")

local buttons = tycoon:FindFirstChild("Buttons")
local purchasedItems = tycoon:FindFirstChild("PurchasedItems")

local objects = {}

if buttons then
for i, v in pairs(buttons:GetChildren()) do
spawn(function()
if v:FindFirstChild("Button") then

local newObject = purchasedItems:FindFirstChild(v.Object.Value)
if newObject ~= nil then
objects[newObject.Name] = newObject:Clone()
newObject:Destroy()
else
v:Destroy()
end

if v:FindFirstChild("Dependency") then
v.Button.Transparency = 1
v.Button.CanCollide = false
v.Button.BillboardGui.Enabled = false
coroutine.resume(coroutine.create(function()
if purchasedItems:WaitForChild(v.Dependency.Value) then
v.Button.Transparency = 0
v.Button.CanCollide = true
v.Button.BillboardGui.Enabled = true
end
end))
end

v.Button.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
if values.OwnerValue.Value == player then
if v.Button.CanCollide == true then
if player:FindFirstChild("leaderstats").Cash.Value >= v.Price.Value then
player.leaderstats.Cash.Value -= v.Price.Value
objects[v.Object.Value].Parent = purchasedItems
v:Destroy()
end
end
end
end
end)
end
end)
end
end



Please answer :D

Ответить
@januvkanal2335
@januvkanal2335 - 28.12.2023 12:06

Hey guys i made the code working for now. CODE:
if buttons then
for i, v in pairs(buttons:GetChildren())do
spawn(function()
if v:FindFirstChild("Button") then

local newObject = purchasedItems:FindFirstChild(v.Object.Value)
if newObject ~= nil then
objects[newObject.Name] = newObject:Clone()
newObject:Destroy()
else
v:Destroy()
end

if v:FindFirstChild("Dependency") then
v.Button.Transparency = 1
v.Button.CanCollide = false
coroutine.resume(coroutine.create(function()
if purchasedItems:WaitForChild(v.Dependency.Value) then
v.Button.Transparency = 0
v.Button.CanCollide = true
end
end))
end

v.Button.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
if values.OwnerValue.Value == player then
if v.Button.CanCollide == true then
if player:FindFirstChild("leaderstats").Cash.Value >= v.Price.Value then
player.leaderstats.Cash.Value -= v.Price.Value
objects[v.Object.Value].Parent = purchasedItems
v:Destroy()
end
end
end
end
end)
end
end)
end
end

Ответить
@amirmostafa7885
@amirmostafa7885 - 27.12.2023 01:34

Thx for the nice video but😅
I have problem with my drppers they didn't drop the paert anymore

Ответить
@dgcroblox
@dgcroblox - 26.12.2023 23:32

i dont have the drops leaderstats?

Ответить
@YTAlex21
@YTAlex21 - 26.12.2023 11:53

dude I literarly tried everything. I dont know what is wrong . I copied the exact same script you put in the comments. I did everything as you said and it still doesn't work. when touch the first button it does absolutely nothing . this is my script it's literarly THE SAME . I spent 2 days trying to figure it out...and nothing. values right literarly everything right



local buttons = tycoon:FindFirstChild("Buttons")

local purchasedItems = tycoon:FindFirstChild("PurchasedItems")



local objects = {}

if buttons then

for i, v in pairs(buttons:GetChildren()) do

spawn(function()

if v:FindFirstChild("Button") then



local newObject = purchasedItems:FindFirstChild(v.Object.Value)

if newObject ~= nil then

objects[newObject.Name] = newObject:Clone()

newObject:Destroy()

else

v:Destroy()

end



if v:FindFirstChild("Dependency") then

v.Button.Transparency = 1

v.Button.CanCollide = false

v.Button.BillboardGui.Enabled = false

coroutine.resume(coroutine.create(function()

if purchasedItems:WaitForChild(v.Dependency.Value) then

v.Button.Transparency = 0

v.Button.CanCollide = true

v.Button.BillboardGui.Enabled = true

end

end))

end



v.Button.Touched:Connect(function(hit)

local player = game.Players:GetPlayerFromCharacter(hit.Parent)

if player then

if values.OwnerValue.Value == player then

if v.Button.CanCollide == true then

if player:FindFirstChild("leaderstats").Cash.Value >= v.Price.Value then

player.leaderstats.Cash.Value -= v.Price.Value

objects[v.Object.Value].Parent = purchasedItems

v:Destroy()

end

end

end

end

end)

end

end)

end

end

Ответить
@Cbowlin21
@Cbowlin21 - 22.12.2023 17:09

every time i touch the first button it says CanColide is not a valid member of Part "Workspace.Tycoons.Tycoon.Buttons.DropperButton.Button" - Server - Core:54

Ответить
@abunnygod
@abunnygod - 22.12.2023 01:40

When I made it, the door stopped working

Ответить
@AnakSerjana
@AnakSerjana - 19.12.2023 06:41

why button not invis

Ответить
@BeatBltz
@BeatBltz - 18.12.2023 19:55

My colorizer is still there

Ответить
@riblolox
@riblolox - 18.12.2023 01:55

whenever i have a second button, even when it has a different name than the first one, when i try to playtest it it says "Button is not a valid member of Model "(button name)"" and when i rename the Button"" part in the second button, it completely breaks

Ответить
@fffd34
@fffd34 - 12.12.2023 22:18

Pls core script

Ответить
@debiddo3145
@debiddo3145 - 06.12.2023 22:06

i get this error "Workspace.Tycoons.Tycoon.Scripts.Core:31: attempt to index nil with 'Colorizer' - Server - Core:31" and i did the exact same things as you and i wrote the code 2 times and still nothing

Ответить
@SkecherGames
@SkecherGames - 06.12.2023 03:09

THE CODE DOES NOT WORK

Ответить
@XenoHosting
@XenoHosting - 01.12.2023 02:55

" Cash is not a valid member of Folder "Players.Pr0x_Z.leaderstats""

Ответить
@cryptex6709
@cryptex6709 - 29.11.2023 22:07

Infinite yield possible on 'Workspace.Tycoons.Tycoon.PurchasedItems:WaitForChild("Dropper")

Ответить
@ericthebestplays1903
@ericthebestplays1903 - 29.11.2023 16:01

this is sad now my owner door doesn't work

Ответить
@ericthebestplays1903
@ericthebestplays1903 - 29.11.2023 15:14

the part where it says: if newObject ~# nil then. this part ~# it gets underlined

Ответить
@TheEmperic
@TheEmperic - 28.11.2023 06:52

i did the script twice, and it just brakes, the colorizer doesnt work, owner door doesnt work, buttons doesnt work, its just all broken, but it worked just fine before i started to edit the script for this episode, and its just sad, i dont know what to do anymore.

Ответить
@Seek204
@Seek204 - 28.11.2023 05:20

is it okay if i only put dropper buttons? because the colorizer button doesnt work.

Ответить
@gamefight5675
@gamefight5675 - 20.11.2023 00:10

I did all step by step but my first button doesnt working what can ı do please help @Rustysillyband

Ответить