Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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 .

0
SomeOne said i could do so. And also i dont get what you mean aleandroblingo -35 — 6y
Ad

Answer this question