-
What do you want to achieve? Keep it simple and clear!
I simply want a way to add a sanity check to this script -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve looked at a lot of posts regarding sanity checks but none seem to fit my criteria
Server script:
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
ReplicatedStorage.RemoteEvents.UpdateInventorySpace.OnServerEvent:Connect(function(plr, CritterName, CritterValue, CritterImage)
local reginventorySlot = ServerStorage.RegInventorySlots.InventorySlot:Clone()
reginventorySlot.CritterName.Text = CritterName
reginventorySlot.CritterValue.Value = CritterValue
reginventorySlot.CritterValueText.Text = "Price: " .. CritterValue
reginventorySlot.CritterImage.Image = CritterImage
reginventorySlot.CritterNameValue.Value = CritterName
reginventorySlot.Parent = plr.PlayerGui.ScreenGui.InventoryFrane.Inventory
reginventorySlot.Name = CritterName
local regSellSlot = ServerStorage.RegInventorySlots.SellSlot:Clone()
regSellSlot.CritterName.Text = CritterName
regSellSlot.CritterValue.Value = CritterValue
regSellSlot.CritterValueText.Text = "Price: " .. CritterValue
regSellSlot.CritterImage.Image = CritterImage
regSellSlot.CritterNameValue.Value = CritterName
regSellSlot.Parent = plr.PlayerGui.ScreenGui.CCKennedyShop.SellingFrame.Frame
regSellSlot.Name = CritterName .. "SellSlot"
local inventorySlot = ServerStorage.RegInventorySlots.InventorySlot:Clone()
inventorySlot.CritterName.Text = CritterName
inventorySlot.CritterValue.Value = CritterValue
inventorySlot.CritterValueText.Text = "Price: " .. CritterValue
inventorySlot.CritterImage.Image = CritterImage
inventorySlot.CritterNameValue.Value = CritterName
inventorySlot.Parent = ServerStorage.Inventories[plr.Name]
inventorySlot.Name = CritterName
local SellSlot = ServerStorage.RegInventorySlots.SellSlot:Clone()
SellSlot.CritterName.Text = CritterName
SellSlot.CritterValue.Value = CritterValue
SellSlot.CritterValueText.Text = "Price: " .. CritterValue
SellSlot.CritterImage.Image = CritterImage
SellSlot.CritterNameValue.Value = CritterName
SellSlot.Parent = ServerStorage.SellInventories[plr.Name]
SellSlot.Name = CritterName .. "SellSlot"
plr.inventorySpace.Value = plr.inventorySpace.Value + 1
end)
Local script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Player = game:GetService("Players").LocalPlayer
local canHit = true
local db = 1
script.Parent.CritterHitterPart.Touched:Connect(function(thing)
if thing.Parent.Name == "Cricket" or "GrassHopper" and thing.Name == "Head" then
if canHit == true then
canHit = false
if Player.inventorySpace.Value < 5 then
local CritterName = thing.Parent.Critter.Handle.CritterName.Value
local CritterValue = thing.Parent.Critter.Handle.CritterValue.Value
local CritterImage = thing.Parent.Critter.Handle.CritterImage.Value
Player.PlayerGui.ScreenGui.Plop:Play()
Player.PlayerGui.ScreenGui.CritterCaptured.Text = "You captured a " .. CritterName .. "!"
Player.PlayerGui.ScreenGui.CritterCaptured:TweenPosition(UDim2.new(0, 0,0.8, 0), Enum.EasingDirection.In, Enum.EasingStyle.Linear, 1, true)
ReplicatedStorage.RemoteEvents.UpdateInventory:FireServer(CritterName, CritterValue, CritterImage)
wait(db)
canHit = true
wait(3)
Player.PlayerGui.ScreenGui.CritterCaptured:TweenPosition(UDim2.new(0, 0,1, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Linear, 1, true)
else
canHit = false
ReplicatedStorage.RemoteEvents.InventorySpaceFull:FireServer()
Player.PlayerGui.ScreenGui["Menu Error"]:Play()
Player.PlayerGui.ScreenGui.Warning.Visible = true
Player.PlayerGui.ScreenGui.Warning.Text = "Full Inventory Space"
wait(5)
Player.PlayerGui.ScreenGui.Warning.Visible = false
end
wait(db)
canHit = true
end
end
end)
The local script is inside of a tool and whenever the tool detects that it hit a critter then it should fire the remote event and tell you what critter you collected.
The server script is what takes all the critters information and puts it into a inventoryslot clones it and puts it into everything needed.
So I just want to know how I could possibly make a sanity check so a exploiter can’t just make they’re own script and fire the remote event with the information needed giving themselves critters and items they’re not supposed to have. Thanks for reading!