Hi everyone! I wasn’t sure if this should be in Scripting Support or Game Design Support so I’m putting it here.
Context:
I have a Script (RunContext: Client) under a ProximityPrompt in a folder named “Essentials” under workspace. In ReplicatedStorage, I have an Events folder with the GiveItem and PayMoney event.
PayMoney is secure enough with checks on the player’s amount of money and seeing if the number isn’t a negative number (To prevent exploiters from calling a negative number on the event and receiving money instead of being deducted money).
What I’m unsure of though is how to secure the GiveItem event, I’ve thought about adding sanity checks but I don’t really know WHAT to sanity check since this event is to be used for not just purchasing items but also for giving items in general when called by the client.
How would you approach this?
Further Context:
ClientSided ProximityPrompt Script:
local Price = 10
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Item = "Bread"
script.Parent.Triggered:Connect(function()
ReplicatedStorage.Events.PayMoney:FireServer(Price)
ReplicatedStorage.Events.GiveItem:FireServer("Bread")
script.PurchaseSFX:Play()
end)
Snippet of the GiveItem Handling on the Server-Sided Main Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Events = ReplicatedStorage.Events
local GiveItem = Events.GiveItem
local function GiveItemFunction(Player, ItemName)
if Player then
local Backpack = Player.Backpack
local Item = ReplicatedStorage.Items:FindFirstChild(ItemName)
if ItemName then
Item:Clone().Parent = Backpack
end
end
end
GiveItem.OnServerEvent:Connect(GiveItemFunction)

