So, lately I had to deal with button that when you click it gives clicks, I used to always just use a localscript and fire a remotevent to give the currency but that would be easy to exploit and can’t be secured, I tried to thank of all the ways I can secure it with when I fire the remote but no clue,
and that is when I tried to use serverscripts in GUIs, not that I have never done it but I didnt think it would work, So it worked well, but I’m really curious about something, to get the player variable I used the path from the script all up to playerguis then player so lets say my script was inside an ImageButton in a screengui to get the player I dolocal player = script.Parent.Parent.Parent.Parentyou get the point, and that is when I actually found so many uses to this instead of using a localscript and firing a remotevent, I still use local scripts but for something like Cloning templates, Rebirthing, Pet Template Cloning I do it serverside using serverscripts in the guis and get the player using the parents so please tell me if it has any DownSides to use this way and if so I will have to change my way of doing this
Also I tried to look for a post alike, there is but its not what i’m exactly looking for so answer this please, thanks!
Yes, there are quite some downsides. For an example. The server will be having to process every instance and function in the GUI’S. Not only that, but the effects / tweens won’t be as smooth since its not running on the client. Resulting a possibility for the game to lag over time or even crash.
Even though you mentioned exploit vulnerabilities. You can still patch it on the server-end with cooldowns and checkups to avoid that.
Big advice , keep your GUI scripts in local scripts.
I wont be tweening serverside, the effects are always in local scripts, so you thing I rather use local scripts and fire a remote other then using a serverscript directly?
Well at first I tried to think of checkups I could do but but theres none when it comes to clicking a button that gives u an amount, you are forced to send the amount in the parameters and you can do no checkups serverside
local player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent
--local Inventory = script.Parent.Parent.Parent.Parent.PetInv.Inventory
local Amount = 100
script.Parent.MouseButton1Click:Connect(function()
local playergui = player.PlayerGui
local Inventory = playergui.Main.PetInv.Inventory
if #player.Character.PetsEquiped:GetChildren() ~= 0 then
Functions.Multiplier(player, Amount, "Multi1", "TClicks")
else
Functions.GiveClicks(player, Amount, "TClicks")
end
end)```
--I use this for my click button (ServerScript)
As a rule of thumb, never handle UI on the server. The client should be in charge of listening to mouse clicks.
That’s actually the right way to do it. You can easily secure this if you do it right. Determine the amount of money you’re going to give the player on the server. Don’t let the player spam the remote event.
For example, let’s say you’re giving a player free points every day. When they click the points button, just tell the server and have the server do everything important. Can the player get points right now? How many should we give them? If you determine they can get points, add up the points and then tell the client they got their reward.
Remotes seem complicated but they’re actually pretty simple. They’re way more reliable than using a server script in a GUI.
Just did some testing on Studio, and the if you put the script on the server it wouldn’t work, but if you put the script inside the GUI it will work. I thought this was interesting, and did some digging because I instinctively use local scripts for all GUIs. Apparently using scripts on GUIs may seem to work, but can be really unresponsive. Well there is the real reason why using scripts for GUIs is bad practice lol.