Hello, I have this script that allows you to buy health by holding down the key on a proximity prompt. As you hold down the key it increases your health in increments of 1 and also decreases your cash in increments of 3. Resulting in 100 health being $300. Everything works properly, however, I’m wanting to know if it’s secure. E.g. should it stay as a script or should it be a local script? Or should it be converted into a Remote Event using both local and server scripts? Another question I have is, is it optimized? Is this the best way I can do this without taking away performance from the game?
local ProximityPrompt = script.Parent.ProximityPrompt
Status = true
ProximityPrompt.PromptButtonHoldBegan:Connect(function(player)
local Status = false
repeat task.wait(0.03)
if player.Character.Humanoid.Health < 100 then
if player.leaderstats.Cash.Value >= 3 then
if player.Character.Humanoid.Health == player.Character.Humanoid.MaxHealth or player.leaderstats.Cash.Value < 3 then
Status = true
end
ProximityPrompt.PromptButtonHoldEnded:Once(function()
Status = true
end)
player.Character.Humanoid.Health += 1
player.leaderstats.Cash.Value -= 3
else
break
end
else
print("Health is already full")
Status = true
end
until Status
end)
ProximityPrompt.PromptButtonHoldEnded:Once(function()
Status = true
end)