#Incremental spawning system
1 messages · Page 1 of 1 (latest)
I dont undestand well but
Firstly
You could just change the module script location to repliczted storage
And secondly, the exploiter cant require the module since we can require it only once (tho i think he can just create a local script with the function of the module and idk just change but idk)
Btw, when an exploiter change the module, the change is not working on the server (ig atleast)
okay so i have a game.
- it spawns parts locally (only for the player)
- there is a max amount that the player can have (can change)
- how do i check that it doesnt spawn more
Well
I used attributes
Like, you set attributes on the server (max amount for ex)
And you get them on client
Always verify attributes on server when you getting coins or idk something like that, cuz the client can exploit like you said
In your incremental game, we have to touch this part to get money?
But the problem is that you spawn them locally
yes
so a good example of a game like this is: https://www.roblox.com/games/120870800305934/UPD-4-5-Sticks-Incremental
or just search: Sticks Incremental
🍃 How to Play Sticks Incremental 🍃
🌲 Collect sticks to buy powerful upgrades.
✨ Discover rare sticks to boost your strength even more.
📈 Progress through unique stages to unlock special upgrades.
🏆 Automate your land and rise to become the #1 stick collector!
👍 Drop a like and favourite the game to support future updates.
...
its pretty much the idea i wanna add
Ye but, problem is that you can never trust the client, so you probably need to spawn the parts on server
locally spawned parts you collect e.g
but how do you do that only for the player
I have a question
while keeping it fast
yeah ofc
When the part spawn on client, how would the server be able to know that the part spawned ?
you want me to send my current code?
but like this is why im here
Maybe set transparency 0 to all the part that is for the player, and transparency 1 for the part that are not for the player (or maybe even destroy them on client side)
You could use a remote event, telling the server that a part has spawned
see i had this idea, but how do you tell only a certain client to show them
yeah thats what i did
let me send my current code
I might be wrong with all I say btw, im not really experimented
Server Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local addedEvent = ReplicatedStorage.Events:WaitForChild("Added")
local updateEvent = ReplicatedStorage.Events:WaitForChild("Update")
local collectEvent = ReplicatedStorage.Events:WaitForChild("Collect")
local getDataKey = ReplicatedStorage.Events:WaitForChild("GetDataKey")
local setDataKey = ReplicatedStorage.Events:WaitForChild("SetDataKey")
addedEvent.OnServerEvent:Connect(function(player)
local char = player.Character or player.CharacterAdded:Wait()
local coinsModule = require(char:WaitForChild("CoinsModule"))
local textLabel = player:WaitForChild("PlayerGui").CollectionCounter.CounterText
coinsModule.actualCoins = coinsModule.actualCoins + 1
print(coinsModule.actualCoins)
textLabel.Text = coinsModule.actualCoins .. "/" .. coinsModule.maxCoins
if coinsModule.actualCoins > coinsModule.maxCoins then
print("Hacking")
end
updateEvent:FireClient(player, coinsModule.actualCoins, coinsModule.maxCoins)
end)
collectEvent.OnServerEvent:Connect(function(player)
local char = player.Character or player.CharacterAdded:Wait()
local coinsModule = require(char:WaitForChild("CoinsModule"))
local textLabel = player:WaitForChild("PlayerGui").CollectionCounter.CounterText
coinsModule.actualCoins = coinsModule.actualCoins - 1
print("Coins", coinsModule.actualCoins)
textLabel.Text = coinsModule.actualCoins .. "/" .. coinsModule.maxCoins
if coinsModule.actualCoins > coinsModule.maxCoins or coinsModule.actualCoins < 0 then
print("Hacking")
else
local inventory = getDataKey:Invoke(player, "Inventory")
inventory.Apple += 1
print(inventory.Apple)
setDataKey:Fire(player, "Inventory", inventory)
end
updateEvent:FireClient(player, coinsModule.actualCoins, coinsModule.maxCoins)
end)```
Client Collect System
local collection = game:GetService("CollectionService")
local replicatedStorage = game:GetService("ReplicatedStorage")
local player = script.Parent.Parent
local coinsModule = require(script.Parent:WaitForChild("CoinsModule"))
local addedEvent = replicatedStorage.Events.Added
local collectEvent = replicatedStorage.Events.Collect
collection:GetInstanceAddedSignal("coin"):Connect(function(part)
addedEvent:FireServer()
part.Touched:Once(function(hit)
print("hit")
print(hit.Name)
collectEvent:FireServer()
part:Destroy()
end)
end)```
Client Spawn System
local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local spawnSite = Workspace.World.MainMap:WaitForChild("SpawningPart")
local coin = ReplicatedStorage:WaitForChild("Coin")
local coinModule = require(script.Parent:WaitForChild("CoinsModule"))
local zonePosition = spawnSite.Position - Vector3.new(spawnSite.Size.X/2,0,spawnSite.Size.Z/2 )
local Player = Players.LocalPlayer
local SpawnSpeed = 2.4
Player:GetAttributeChangedSignal("SpawnSpeed"):Connect(function()
SpawnSpeed = Player:GetAttribute("SpawnSpeed")
end)
while task.wait(SpawnSpeed) do
if coinModule.actualCoins < coinModule.maxCoins then
print(coinModule.actualCoins, coinModule.maxCoins)
local coinClone = coin:Clone()
coinClone.Parent = workspace
coinClone.Position = zonePosition + Vector3.new(math.random(2, spawnSite.Size.X), 1.5, math.random(2, spawnSite.Size.Z) )
else
warn("Max Coins", coinModule.actualCoins)
end
end```
Maybe you create a foler in workpace containing folders named from the player user id, and the spawn parts in this folder
okay but lets say if i was to detect parts added, this wont work because the exploiter could easily just make parts
We are talking about creating parts on server for the moment right ?
If the exploiters create a part on his client side, the server wont see this part
yes thats what you said
ahh right good point.
But like I said, dont trust 100% what I did, i dont know what i dont really know much too, i just tried to help
Hope someone that knows better can explains it
Like if spawning the parts on client is a problem?
But ig yes but idk
yeah i know what you mean
this is so much harder then it seems and its really bugging me
okay but now another issue
how would spawn parts at different times for each player
Hm
Why not creating a thread when a player joins thats a loop that create parts each x time, where x is the spawn rate of the player
Like : lua task.spawn(YourSpawnFunction)
On player added obviously
and how could i update the thread on the timing?
About the spawn rate you mean ?
yeah
You dont have to "update" the thread, just make sure your function update it
For example in the while loop, you set back the spawnrate to a new one if the player have upgraded it
Like :
local playerSpawnRate = 3 -- seconds
while task.wait(playerSpawnRate) do
-- here you actualize your playerspawnrate variable, like : playerSpawnRate = Player:GetAttribute("SpawnRate")
-- function to spawn part or idk
end
I mean i really wrote this fast
Idk if you got it
@toxic yarrow
If no tell me
okay i got it working
it seems to work thanks man
but i got another question
what would be the best way to add a collect system now?
When you say collect system
You say like a zone where you collect
Or a touched event
yes
not sure if you tried the game i linked
but like that
Y
A better method would be to spawn the parts on the client but have the part count on the server
You can check the player distance with the part
How would you count the part
A server sends a remote event to the client
If the client sends it back you count it down
Nice, now, how would you get the part position for example?
Wdym? Remote event that fire position?
with a while loop?
The exploiter could teleport all the parts to him but either way its better than having hundeards of parts on the server destroying themselfs and cloning back in miliseconds
Especially models
Unless you create part on server and then put the ownership of the part to the server
What would that change?
The part spawns on the client
If the server does that memory leaks and server lag wouls become a problem
Well, player wont be able to put all parts to his position
And youll jave to rekoin to new servers alot more often
No like if its on server
Yes
Why?
okay so im confused
@river cosmos your saying client right
this is the code i used
Because cloning and destroying n stuff adds a little bit of memory or sum that you cant destroy unless you go into a new server
./
what do you think of this
i had the issue where i was unable to keep track of how many parts where currently spawned across server and client
You sure about that? Isnt the garbage collector thing or idk what just delete that ? And so you suggest doing it on client even tho it will be really easy to exploit?
It doesnt really fully delete it
As the server get older it lags
Its just better to do it on the client, because of alot shorter delays and longer server life
That means more servers will be faster
Shorter delay
Cant you just shutdown the server after x time
And like make players rejoins
Eh
Ye but this would like
Ruin the competivity
With other players
I know
But maybe you could make some infos about like the part on server actually, like the part pos, the part type, etc.. and then fire it from server to client to make the client create the part but id'
The only stuff i see n stuff is handle the logic on the server and objects on client
I mean you could make this all server sided but ion recomend
okay so what do you recomend
and what do you recomend i do differently from my code?