Hello, all of you wonderful programmers! I'm PingyPenguin7, the young (and I mean young) programmer, and I will help you get a start on building your very first TYCOON! :D
NOTE: This tutorial will only cover the basic fundamentals needed to build a tycoon. Everything else, like better droppers, or even a different currency, is just an expansion on what I'll teach you here. Also, this is an EXTREMELY long tutorial, as I explain a lot of stuff. Because of the mass amount of information, I will be updating it regularly with new info about every week until I completely finish.
I struggled making my own tycoon because at the time, I didn't really know what I needed to do. Essential parts, like droppers and ESPECIALLY tycoon buttons, gave me trouble because I struggled to find resources that actually gave me what I wanted. Maybe I just was a bit picky or didn't research hard enough, who knows? Anyway, I'll share what I've figured out and make life easier for you.
Let's get started!
I'll start off with something rather basic, some leaderstats for currency. I know there is a tutorial that already covers this, but I'll post the script for it here anyway.
Also, create a new script in ServerScriptService and name it "Leaderstats".
game.Players.PlayerAdded:connect(function(plr) local leaderstats = Instance.new("Model",plr) leaderstats.Name = "leaderstats" local money = Instance.new("IntValue", leaderstats) money.Name = "Money" money.Value = 0 end)
What this script does is create a leaderstats object, and then place an Int Value that represents the money or other currency we want to use. When you play the game now, you should see a new column for "Money" with a value of 0.
On to the next step!
You play a tycoon game, and the first thing you see is a bunch of empty tycoons with doors. You walk up to a door, and you claim the tycoon! That is what I'll be showing you next.
First, create a cube object and make it into a door. Make it into a model by pressing Ctrl + G and put a Humanoid in the model. Rename the part "Head" and rename the model "OwnerDoor". If done correctly the door should look like this. Also, make sure to put a string value named "OwnerName" inside the "Head" part.
Create 2 new scripts; Put one in the model and the other in the "Head" part. Put this code in the model script:
--Variables local model = script.Parent local owner = script.Parent.Head.OwnerName --Initializes Name function check() if owner.Value == "" then model.Name = "No current owner" else model.Name = owner.Value.."'s Tycoon" end end --Whenever owner value is changed, then run the check() function owner.Changed:Connect(function() check() end) check()
Let me walk you through this script. The two variables reference the model and the OwnerValue inside the "Head" part. The check() function will change the name of the model depending on the value of OwnerValue. That's all you really need to know.
Now, it is time for the script in the "Head" part.
local owner = script.Parent.OwnerName local isOpen = false local waitTime = 2 local door = script.Parent --Ensures that the door is closed at the start door.Transparency = 0 door.CanCollide = true door.Anchored = true script.Parent.Touched:Connect(function(hit) local humanoid = hit.Parent:FindFirstChild("Humanoid") if humanoid then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then --If there is no owner if owner.Value == "" then owner.Value = plr.Name --If the player is already the owner elseif owner.Value == plr.Name then if isOpen == false then isOpen = true door.CanCollide = false door.Transparency = 0.8 wait(waitTime) door.CanCollide = true door.Transparency = 0 isOpen = false end else --Not the owner humanoid.Health = 0 end end end end)
Long script I know. Anyway, this script determines if the player touching it is the owner or not. If there is no owner, it makes that player the new owner. If the player is already the owner, then the door opens for it. Otherwise, it kills the other players.
If tested the owner door should make you the new owner when you touch the door. Afterwards, it will open the door for you. That is pretty much it for the owner door!
That is all the info I have done so far (10/25/19). I should come out next week with our very first dropper! Manual, of course :P. Bye!