Roblox Tycoon Scripting Tutorial (Part 2)
Вставка
- Опубліковано 1 жов 2024
- Part 2 where we will learn how to set up the buttons and position items on a player's plot. This series of videos will show you how to make a tycoon on Roblox in 2024, we will be going through everything you need to script in order to make a basic tycoon. More videos coming soon.
Project files available to Premium channel members: www.youtube.co...
Video for members on how to download project file: • How To Access Project ...
Discord: / discord
Twitter: / alvinblox
Roblox: www.roblox.com...
Become a channel member to get the project file and source code: ua-cam.com/users/alvinbloxjoin / Part 3: ua-cam.com/video/C_k6E_49ldc/v-deo.html
Please give Freee please MAKE ITTTTTT why you want 5$????????????
He literally explained it in these videos, why do you need it automatically when you can just make it with his tutorials
I'm a 14 year old Brazilian, my dream is to own a great Roblox game, to make it happen I use your videos, the only problem is that I don't have many people to help me with the project, but still, thank you Alvin ❤️ 👍
Hope your dream comes true 🍀
@@BubBBleBoy Thanks man, may the same happen to you, one day you'll be playing my Roblox game 🫡👊🏻
@@MiguelVidal-mh4ie.If you want, we can be a team together. We can make games with our experiences.
Love to hear this! All the best my friend
I hope your dreams come true Miguel
I thought I was a fast typer, now I realised something…
me too
Same
Can i fix it somehow
when you are coding this make sure its the same cuz i was stuck on the button going to the plot and i put cfame not cframe in one of the spots
can you make it so the buttons gradulaey appear like you purchase the first then second and maybe make it so the items slowly fade in :) also do you release the source code?
Source code is available to Premium Channel Members via my Discord server. You will need to connect your UA-cam account with Discord in order to view the project-files channel.
@randomguy69697 paying so he can get money and u can use it
@randomguy69697 it is what it is. Deal with it.
Hey Alvin, keep up the good work, your videos are the reason I´m interested in scriptinh
Can someone please share their working code I have been trying to see what I did wrong for hours but I cant find anything.
am i the only oen where the buttons don't generate on plots??
Ur not the only one also me
check if the buttons and items folder has smth in it it should have the button and poster
yeah ☠️
try adding: TemplateButtons.Parent = tycoon
hey alivn so when i joined i didnt see the button on my plot is there somthing i did wrong?
probably not anchored or somthing is destryoying it so figure out whats destroying it
that happened to me for me it was i mixed the model code with the part code
something is not working at the end of the video and i noticed that you put local itemcframe but did not put = ... i wonder if that is what making it not work but it works for you
I have a squiggly under "itemToUnlockId" in Line 40 saying 'Unknown global 'itemToUnlockId' 😔
had the same thing u just have to add and end at the end
I am following this now. For me I had to change it from "itemToUnlockId" to "itemToUnlock" and it fixed it.
Thx for the help alvian also could you make a series on how to make a story game i know you have done this topic before but can you do a video on how to make a modern story game with all of the cutsence Boss Fights badges and Vote to get an ending?
@AlvinBlox, can you help me? Even though I touch the part, the poster is not appearing. PLEASE HELP!!!
SAME!! I've tried different models and changing things around, no luck.
Same here too
@@butterboi.G.I.F I got it to work!
@@BrownSkinFriend how?
Isn't there a more organized way to identify an purchable item? because using numbers(ID) can make you easily lose the item in the middle of the tycoon, and if to change one item you will have to look around the ID of the item all across the tycoon.
I wonder if this will work well with strings instead of numbers...
I noticed near the end when you step on the button and the item multiplies, they say to do a certain code to delete the button after you step on it that did not work for me. Instead of doing that, insert a script into the button with this next set of code and it will delete on touch; function touch()
script.Parent:remove()
end
script.Parent.Touched:connect(touch)
my button isnt there...
Alvin can u pin me
i like ur vids
👋As a roblox developer i dont agree with your way of asigning models to the buttons, it would be really tedios to every time you add a model scroll down to the attributes, click add atribute, set the type to number (allthough as you pointed out it can be a string) and remember witch id it is supposed to be and do the same for the coresponding button,
i would just add an... i think its called object value or instance value into the button and set it to the instance model it is supposed to be connected to.. also it would be much more efficient cuz the code does not have to check everything, it can just get the instance from the value
that said your solution is valid and coded good just not really efficient... i hope you see this actually, i want to know why you didnt use the instance values, did you just not think of it?
I work with object values all the time, it definitely saves a lot of time (and loc), I've done the old way as well and its an absolute horror to work with now
yeah uhh.. so alvin, if you read this and you dont have more like pre-made episodes, you can change it if you want, feel like it would be a better example of tycoon game code that way
@@frankie4073 yeah they can be usefull, its a shame we cant make object attributes
I agree. I really dislike the style in which he makes these games. A lot of inefficient scripts and overcomplicated things for no reason..
@@NikolasH123 object attributes could be useless though, object values are there to exist to get object in the game via scripts more easily and without worries of filtering enabled.
For example, I use dynamic object values from time to time, that would get useless sometimes, means more workarounds for me
Hello, im a 11 yo brazilian, i really want to make a military like tycoon, im sure these tutorials will help me a lot! Thx man
It would be nice if you could teach us the "Proximity prompt" alternative. Thanks! Love your vids!!
Just use a proximity prompt activated event instead of a touched event.
had a sigh of relief when he used a billboard gui instead of a viewer humanoid
hi
I put the item as a conveyor and near the end of the video I was confused why the conveyor wasn't appearing so I checked the output multiple times and it kept saying that I forgot to put the id thing and after 10 minutes I was looking at id part of the video and I looked at the id name I put and I accidentally put "IdOfItemToUnlocked" LOL
Oof
nvm my other comment it works but sometimes it shows my model on the items folder but it dosent show the button even though the button loads, if i stand on the button it works but my model gets created at the bottom of the map close to the spawnpoint. sometimes its vice-versaand even if i stand on the button then nothing happends (pls excuse my grammar)
Would this script work for more droppers/models/parts? To include them would I need to write more code on my own or can I use the one provided in the video? Thanks for an answer in advance
works for more. As long as they have all of the attributes you don't need to write any more code
Hey, great video, but i am having trouble with the BaseParts not spawning at the new plot and only on the original Template plot
Guys I need help when u said that the starter pack would spawn on ur plot it didn't spawn and I don't know how to get a plot or make it spawn so pls someone respond on this
Bro, I need help ASAP
For some reason when I do Button:Destroy()
It just completely deletes the buttons folder, what am I doing wrong??????
Either your Buttons folder is labeled as “Button,” or you accidentally typed Buttons:Destroy() in your code.
Although I have no idea what I’m talking about, I code in C and want to learn Lua so I could get some passive income while I study for engineering.
@@EKEKEKEKEKEKEKEKEKEKEKEKEKEKEK in the exact same boat as me lol
thx you dude! ive been wanting to make one for like.. years!
it doesnt work when i step on the button idk why
same
the model spawns right where the button was how do i fix it? great tut btw!
make sure in worldCFrameOfNewPlot it says relativeItemCFram not just relativeCFrame had the same issue
this took me so long😅
WHAT DOES Touched is not a valid member of Model "Buttons.Button" MEAN??
It means that button is likely a model and not a part
make sure "CanTouch" is true in properties
@@the_big_cheez I don't see that property, you got any idea what I can do?
@@a1bot_robotroid Its a model not a part
@@the_big_cheez i fixed it, thx anyway
Hey, for some reason the things from the TemplatePlot are not spawning to the plots given to the players. I have seen quite many other people in the comments having the same issue.
Use the output to check if theres an obvious issue its seeing
Hi guys! I was just wondering what to do if my button is a model. The Touched thing doesn’t work!😅 it would make my day if anyone’s could help!
use a proximityPrompt
@@bgducoin so button.ProximityPromt:Connect(function(hit) ?
@@Turtle_games15 did u figure it out?
@@Fonzi2no 😅
Hi Alvin great tutorial, just need help it says TemplatePlot not apart of workspace how to i fix it
Guys can you help me, my model isnt spawning in good place, how to fix this?
DONT WORKED 😭😭😭
im sorry that happend to you :(
This is 100% me ):
Just so yall know, when i wrote the code, I had bugs. Few capitalization errors and using . Instead of : (used to java programs). Chat gpt can help identify and explain the problems if needed
can you help me it says Touched is not a valid member of Model "Buttons.ButtonModel" - Server - PlotHandler:35
Can someone reply to me with the scripts I keep messing it up and to lazy to keep on checking them
im so lost 30:46
Im at 18:06 and i got the message "parent is not a valid member of Folded "Buttons""
How do i fix this?
shoutout for the worldCFramOfNewPlot and for the itemToUnlockId / item to unlock kid
What’s that plugin that’s displaying the parts size when you scale it
I think it's a beta feature.
new feature
When the button is supposed to go to your plot, it’s not going to my plot, can someone help?
i. give. up. EVERYTIME I TRY TO DO THE SAME THING AS 5:08 THE TEXT IS CUT IN HALF
Size: {0.95, 0},{1, 0}
Position: {0.5, 0},{0, 0}
AnchorPoint: 0.5, 0
in the data section of TextLabel's property, correct ?
i have an error it says CFrame is not a valid member of Folder "Buttons" and i did everything right
I really like this series because when i make a mistake i'm able to go back and fix it very easily
Alvin can you please help me bc when I do itemClone.Parent = ItemFolder the code gives me a orange under line plsss help me😢 bc I worked so hard :(
When i noted the video time in the code the coding assistant suggested "lol" IT WAS LATHING AT ME!
Alvin if u have any time i rly need help as i did smth wrong but i cant find it as i got 2 problems, first the poster spawns in the button and second when the button dissapears when i step on it it stills spawns 4 posters and not one
what if you're part is a mesh?! 🗿
WHERE IS SCRIPT
☠
write it yourself you lazy ahh
why is my button not cloning onto my other plots? all the script is identical
Hi alvin i need help my item is spawning in the middle of the button. Pls help🙏
ALL MY SCRIPTS IN PLOT HANDLER GOT DELETED
No idea why but the button didn’t work. Can you please help?
Edit: I got it working, it was two typos.
You said that sometimes the button does not come up. Can you tell me why? My button is not working. I'm not getting the button on the plot.
When a plot gets assigned to me, all the template plot does is just goes into the folder where my plot is, and it doesn't make a copy. Can someone give me a solution?
Idk why but im 10 and i try to make roblox games learn scripts idk why
For yall who are stuck on the first button. Check if there is a button(part) in the buttons folder.
My button doesn’t work and I have spent hours trying to spawn my model - can anyone help me
I’m having problems with the CFrame - it doesn’t know what one is
im confused? itemToUnlockId is underlined.. What do i do
Guys how to I fix that the model spawns very far from the button? 😢
It says in output screen the you forgot to add an idofitemtounlock attribute even though i have. what do i do ?
When i tried running the script, i got an error that says “Touched is not a valid member of model “Buttons.Button” anyone know how to fix this?
I had the same error, you just need to map it to a part instead of the whole Model of the button. Ex.:
Button.ClickablePart.Touched etc.
Btw, I noticed you used "Buttons" but it should be "Button" singular since you're already going through all the "TemplateButtons" in the for loop.
Hope this helps! :D
10:42:01.739 name is not a valid member of Folder "Folder" - Server - PH:18
10:42:01.739 name is not a valid member of Folder "Folder" - Server - PH:18
I did the code exactly how you did it but the model doesn't clone inside of the Items folder, only the folder.
when i join the game it doesnt duplicate the stuff
you know what would be great, a incremental tutorial (games like grass cutting incremental, generator incremental, etc)
im starting trying to learn coding on roblox but i hit a roadblock where i don't know how to make a textlabel change based on the varabile of how many times a part is clicked (my first game is gonna be very simple)
@@ooaktree its really not that hard, just get a ClickDetector setup on the button you wanna click, add a script to your button, then just make a variable like 'local clicks' and then write script.Parent.ClickDetector.MouseButton:Connect(function)
clicks = clicks + 1(or your desired amount)
end
@@ooaktree use linear copilot or similar resources, also for updating a text label for cash I currently use this:
-- LocalScript under the GUI button
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UpdateCashEvent = ReplicatedStorage:WaitForChild("UpdateCashEvent")
script.Parent.MouseButton1Click:Connect(function()
-- Assume the amount is predetermined or maybe calculated based on some logic
local amountToAdd = 1
UpdateCashEvent:FireServer(amountToAdd)
end)
on the client side, and this:
-- Script in ServerScriptService
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UpdateCashEvent = ReplicatedStorage:WaitForChild("UpdateCashEvent")
local function updatePlayerCash(player, amount)
-- Safeguard to ensure leaderstats and Cash exists
local leaderstats = player:FindFirstChild("leaderstats")
if not leaderstats then return end
local cash = leaderstats:FindFirstChild("Cash")
if not cash then return end
-- Update the player's cash
cash.Value = cash.Value + amount
end
UpdateCashEvent.OnServerEvent:Connect(updatePlayerCash)
on the server side. Keep in mind, this uses another script for a button in the GUI the player can click to earn money. This code may be helpful for you, so long as you modify it some to better suit your needs
ALVINBLOX ARE GOAT!!!
👇WHO AGREES!!!
The clone to other plot doesnt work for me 18:05
same here, everything was going smooth until this point. i need help as well :/
Lmao my tree is spawning, but not in the correct position. It’s so over for me.
fixed it but the other parts of my model arent coming to the place theyre supposed to be in and theyre not in the folder
5:41 I'm saving this for later.
Can someone pls send this script in the comments because it doesnt work for me ? pls
some of the things aren't their like the adornee for the button or the thing to make the text say something :/
@Alvinblox please help how to make a tycoon 1 i completed and it worked and i followed all of you steps from name of item to mouse clicks basically a copy of what you did, and tycoon part to the script wont work! it assigns me a Plot but wont copy over the button and item to the plot im assigned! ive been retrying this for 2 months now evey other week i try the whole thing again and again!
12 year old, from pakistan! 13 in a 6 months
If all plots are to have the same items, would the IDs mess that up? So take the poster for example, which has been given an ID of 1, if I were to copy/paste that poster and its button to all plots would it matter that they have the same ID on different plots or would it not matter because it's a different plot? I don't want to end up buying a poster on someone else's plot if you get what I mean. Sorry if I didn't explain very well.
no it wouldn’t matter
i got an error message saying that touched is not a valid member of my model
im confused. where can i get the code or is it what he is typing in the vid because i wanna copy and paste
Hello, great video! I learnt quite a lot! But I do stumbled across a problem with the last line of the code, which is the Button:Destroy()
it seems to remove the button before I even pressed it. Any tips on that?
nvm, I figured it out :D
It is saying parent is not a valid member of folder buttons
how can a video be this long rtgthrytdgfsfsgghfd
im a 9 year old bulgarian i rlly wanna make a game, i hope i make it work :)
Anyone have any idea why the poster would spawn exactly where the button was after stepping on the button? Its causing me some real struggle.
Same have you fixed this?
@@r7aggr096 SO oddly enough, NO! My friend who is learning along side me, it worked for her and she passed me her code. I cant see much difference between our codes... but if i run hers, poster goes up just fine.. :/
the AI coding thing suggested almost the same code
25:11 just saving my spot
i dont know how to make the dropper pls explain it next time
For those who button is not appearing when u join the game try this game.Players.PlayerRemoving:Connect(function(player)
for _, plot in Plots:GetChildren() do
if plot:GetAttribute('Owner') == player.UserId then
plot:SetAttribute('Taken', false)
plot:SetAttribute('Owner', nil)
local ItemsFolder = plot:FindFirstChild('Items')
if ItemsFolder then
ItemsFolder:Destroy()
end
end
end
end)
it worked for me
Where do i put this script
Bro I can’t place the model in the items folder please help me😢
6:50
Studs offset doesn’t appear for me on my properties
how to set adornee to button?
But this tutorial for..... old
How do you measure studs
If someone else like me had a problem of the model spawning additional times (2 or 3 even), even despite destroying the button, you can do this:
Add a line:
"local itemClone = nil" under the "-- load buttons" comment.
Then you can check if an object has already been spawned with this line:
"if itemClone ~= nil then return end"
right after the
"if item:GetAttribute("id) ~= itemToUnlockId then continue end".
If the item has already spawned, the itemClone won't be a nil, and the loop will perish. Also cool if you don't want to remove the button for some reason. Thanks for the tutorial, really help to understand how stuff is made in lua and also glad that you're making it modular and reusable already.