Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

value of fuel change inside the vehicle on part touch with this module script How can i do it?

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

1 answer

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 .

1 comment

0

SomeOne said i could do so. And also i dont get what you mean

This discussion is preserved as it was. New answers, comments, and votes are closed.