You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I’m working on a tycoon game where you have to print money and own a buisness illegally.
I’m working on a pad that increases the printer security. -
What is the issue? Include screenshots / videos if possible!
It just adds it, and resets it to it’s original value:
I would upload a video if roblox could.
3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have but they were dealing with value objects
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
First script:
local PrinterUpgrader = {}
PrinterUpgrader.__index = PrinterUpgrader
function PrinterUpgrader.new(Part,Type, Amount, Cost)
local Upgrader = setmetatable({}, PrinterUpgrader)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EventsFolder = ReplicatedStorage.Events
local WantsToUpgradeEvent = Instance.new("BindableEvent")
local Upgraded = Instance.new("BindableEvent")
local SoundService = game:GetService("SoundService")
Upgrader.WantsToUpgrade = WantsToUpgradeEvent.Event
Upgrader.Upgraded = Upgraded.Event
Upgrader.Type = Type
Upgrader.Part = Part
Upgrader.Amount = Amount
Upgrader.Cost = Cost
local Printer = EventsFolder.GetPrinterObject:Invoke()
local Prompt = Instance.new("ProximityPrompt", Part)
Prompt.ObjectText = "Printer Upgrader"
Prompt.ActionText = "Upgrade"
Prompt.RequiresLineOfSight = false
Prompt.Triggered:Connect(function(player)
WantsToUpgradeEvent:Fire(player)
if player:WaitForChild("leaderstats"):WaitForChild("Cash").Value >= Cost then
print('Can afford')
player:WaitForChild("leaderstats"):WaitForChild("Cash").Value -= Cost
ReplicatedStorage.Events.PlaySound:FireClient(player, game.SoundService.SpentMoney)
if Type == "Security" then
Printer.Security += Amount
print("Printer Security: " .. Printer.Security)
Upgraded:Fire(player)
elseif Type == "Amount" then
Printer.PrintAmount += Amount
Upgraded:Fire(player)
elseif Type == "Paper" then
Printer.Paper += Amount
Upgraded:Fire(player)
end
end
end)
return Upgrader
end
return PrinterUpgrader
Second script
local Printer = {}
Printer.__index = Printer
function Printer.new(model)
--Variables (Initialization and Declaration)
local SoundService = game:GetService("SoundService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local NewPrinter = setmetatable({}, Printer)
local PrintedEvent = Instance.new("BindableEvent")
NewPrinter.Paper = 15
NewPrinter.Security = 10
NewPrinter.PrintAmount = 15
NewPrinter.Printed = PrintedEvent.Event
local Prompt = Instance.new("ProximityPrompt", model)
Prompt.ObjectText = "Printer"
Prompt.ActionText = "Print Money"
Prompt.RequiresLineOfSight = false
--Behavior
Prompt.Triggered:Connect(function(player)
local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
if cash:IsA("IntValue") and NewPrinter.Paper > 0 then
cash.Value += NewPrinter.PrintAmount
game.ReplicatedStorage.Events.PlaySound:FireClient(player, game.SoundService.GainMoney)
NewPrinter.Paper -= 1
NewPrinter.Security -= 1
end
if NewPrinter.Security == 0 then
Prompt:Destroy()
ReplicatedStorage.Events.PlaySound:FireClient(player, SoundService:WaitForChild("CopsArrival"))
player:Kick("The cops caught you printing cash")
end
PrintedEvent:Fire(player)
end)
return NewPrinter
end
return Printer
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.