0

# [SOVLED!!] Script Taking double the cash it needs to?

KixWater 111
1 month ago
Edited 1 month ago

Hello, so I am currently trying to code a script where when a player presses a button, then it will fire a remote event to the server and check if the player has enough money, if they have the item, and if they have a bool value in a folder that I made. The problem is that when the player presses the button, it takes away double the amount it needs to. For example, if I want to take away $50, it takes away$100. Here's the code:

-- Local Script

local repStorge = game.ReplicatedStorage
local RE = repStorge:WaitForChild("RemoteEvent")

script.Parent.TextButton.MouseButton1Click:Connect(function()

RE:FireServer("dfds5f4df165fds4f")
end)

--Server-Script

local repStorge = game.ReplicatedStorage
local RE = repStorge:WaitForChild("RemoteEvent")
local Halos = {game.ServerStorage.Halo, game.ServerStorage.CartoonyHalo}

local EquippedHalos = Instance.new("Folder", plr)
EquippedHalos.Name = "EquippedHalos"

end)

RE.OnServerEvent:Connect(function(plr, key)
if key == "dfds5f4df165fds4f" then
local Halo = game.ServerStorage:WaitForChild("Halo")
local char = plr.Character
local EqHalo = plr:WaitForChild("EquippedHalos")
-- Variable's

local function checkFol()
for _, halo in pairs(Halos) do
for _, v in pairs(EqHalo:GetChildren()) do
if EqHalo:FindFirstChild(halo.Name) then
return true
else
return false
end
end
end
end

local function checkForHalo()
if char:FindFirstChild("Halo") then
return true
else
return false
end
end

local hasHaloOrNot = checkForHalo()
local hHON = checkFol()

if money.Value >= 20 and not hasHaloOrNot and not hHON then
local ClonedHalo = Halo:Clone()
for _, v in pairs(Halos) do
money.Value = money.Value - 20
if not plr.EquippedHalos:FindFirstChild(v.Name) and ClonedHalo.Parent ~= char and plr.EquippedHalos:GetChildren().Name ~= v.Name then
print("Working!")
local NormalHalo = Instance.new("BoolValue", plr:FindFirstChild("EquippedHalos"))
NormalHalo.Name = "Halo"

ClonedHalo.Parent = char
break
end
end
end
end
end)


Please always feel free to comment something that I missed or a solution to this problem that I am facing. Have a great rest of your morning / day / night!

0
Firstly, sending a key is redundant. Commercial Script-injectors are commonly equipped with decompiling tools as well as FE-Instance argument tracers, which make determining a key of this sorts laughable. Ziffixture 6785 — 1mo
0
Also, you're iterating over every Halo within the 'Halo' array, which just so happens to contain two Halos. Your conditional statement also hosts a syntax error with your 'GetChildren' call on 'EquippedHalos'. The code-context suggests that you're attempting to reference the key 'Name' of a Dictionary, which already rises two conflicts. Both of these factors will cause your deduction line to bug. Ziffixture 6785 — 1mo
0
I know I can use :GetChildren() it's just that this is a test for the game I'm making so I just came here quickly to see why it didn't work. And the reason why I did a key is because exploiters can try to put in another key to get the items for free so I made a key. If you know how to make something better, please post something. Thank you. KixWater 111 — 1mo
0
Start with properly designing a system that lacks this vulnerability. Ziffixture 6785 — 1mo