MAIN SCRIPT
--[ Fuel ]--- local FuelScript = require(game.ServerScriptService.Main:WaitForChild('FuelGiver')) FuelScript:Fuel()
MODUE SCRIPT (INSIDE MAIN SCRIPT)
local Module = {} function Module:Fuel() end local Points = game.Workspace.Game.PetrolPoints:GetChildren() local ready = false Points.Touched:connect(function(hit) if hit.Name == "DriveSeat" then car = hit ready = true if hit.Fuel.Value < 10 and ready then repeat wait(0.2) car.Fuel.Value = car.Fuel.Value + 0.2 until ----CHANGE TO 10 LITRES ready == false or hit.Fuel.Value > 9.9 end end end) Points.TouchEnded:connect(function(y) if y == car then ready = false end end) return Module
ModuleScripts don't handle events. Put all of your code with some parameters in the function, also it didn't work because none of the code was inside of the function .