Hiya, how would I go about making a tycoon? As in how would you load certain parts/models in when they are purchases and so on; as I am interested in making a tycoon but I am not sure which approach I want to take.
Thank you.
Hiya, how would I go about making a tycoon? As in how would you load certain parts/models in when they are purchases and so on; as I am interested in making a tycoon but I am not sure which approach I want to take.
Thank you.
Well, you could use „Tycoon Kits“, for example Zed‘s Tycoon Kit
when you don’t want to script much. And try to not use the Toolbox
Hiya, I’d rather script my own custom one to be honest.
Well it would be a fairly large matter, as there are quite a few fundamentals to tycoons. But what you most likely are thinking of are the small green buttons that grant you items and pieces of your building, which would be super simple to script. Plus the gear boxes/tubes, which would also be pretty easy to script.
Yah so how would u do that aaaaaa
Store the pieces in ReplicatedStorage.
In ReplicatedStorage, create a folder for each slot and store the pieces. Load them in whenever you need to.
Basically for the buildings you’d just go:
-- This is written like a normal Script, not a LocalScript.
local TouchPad = script.Parent
local Building = --perhaps inside a folder in ServerStorage or ReplicatedStorage.
-- It would probably be something like a wall, or a roof.
local Price = 1000 --or something else
local PlayerPlot = script.Parent.Parent --or something a little more sophisticated
TouchPad.Touched:Connect(function(otherPart)
local Character = otherPart.Parent
local CharacterHumanoid = otherPart.Parent:FindFirstChildOfClass("Humanoid")
if Character and CharacterHumanoid then
local Player = game.Players:GetPlayerFromCharacter(Character)
if Player then
local PlayerLeaderstats = Player:FindFirstChild("leaderstats") -- or a simple value inside of the player
local MoneyValue = PlayerLeaderstats:FindFirstChild("Money")
if MoneyValue and MoneyValue.Value > Price then
local BuildingClone = Building:Clone()
BuildingClone.Parent = PlayerPlot
end
end
end
end)
You could also take some inspiration from zed’s tycoon kit but i made some tycoon kits in the past and they’re fairly easy to make, you would have to make a main module for the tycoon itself and put in some functions such as :Purchase(modelName), :Load(tycoon, player), :Grant(tycoon, player), etc…
Also there would be alot of communciation between client and server for instance .Touched for the buttons, .AddMoney, etc…
Make sure to keep your code organized cause the module will eventually become super messy.
Yeah, I would recommend using a ModuleScript, if anyone doesn’t know how it works, check out All about Object Oriented Programming
You put your .Touched
buttons on the client and used RemoteEvents? O_O
Well you could also do that actually putting the buttons on the client makes it way easier for the server to handle lag and replication issues so that should be prioritized but up to you, using .Touched should always be executed on the client, using it on the server will not detect it precisely.
You shouldn’t store it in ReplicatedStorage. Instead, store it in ServerStorage so the client can’t see it but the server can.
Why send that over the server/client boundary when you could just do the .Touched
events on the server? It’s reliable enough, in this case, for hit detection to not matter all that much + you don’t need to use a RemoteEvent.
No, the server can’t handle .Touched events as precisely, it could but there would be a delay and networking issues. Using it on the client is more efficient.
I’ll experiment with it later, but you could be right. I’ve just always done .Touched (for tycoons) on the server.
Do you think proximityprompts could work better than touch events?
It could definitely work better, but i recommend using touch events as it is easier for the player to purchase a button than clicking everytime
The Touched event is sent from the client to the server (because the client has network ownership of the character), so on the server it’s just as precise.
If you use it on the client it needs to be sent to the server either way, so using it on the server is basically the same as using it on the client then sending it to the server. I think it might technically be more efficient though, since it would only need to detect the touched event on the client’s side. Either way works fine though. As far as I’m aware, most tycoons do it from the server.
Edit:
Never mind, I wasn’t aware of this problem! I’ll do some testing and look into it, thanks for letting me know.
I’ve debugged that subject months ago and i can confirm that after resetting your character, touch events become more and more delayed, having connections on the server shouldn’t be the way to go, you could be having memory leaks without knowing and a massive lag, however creating these connections on the client will disconnect them upon exit.
four steps