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

I cant seem to see whats wrong,It does not seem to be filling up the object, Anyone help?

Asked by 6 years ago
Edited 6 years ago

ServerScriptService.EventsSearch.Search:9: attempt to index local 'hit' (a nil value)

--// For Fill detector //--

local Fill = Instance.new("RemoteEvent", workspace.Events)
Fill.Name = "FillEvent"

Fill.OnServerEvent:connect(function(player, hit)
    warn(player.Name)
    local ready = false
    if hit.Name == "DriveSeat" then
        warn("OK, working FAR")
        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 
            ready == false or hit.Fuel.Value > 9.99
        end
    end
end)

script.Parent.TouchEnded:connect(function(y)
    local ready = false
    if y == car then
        ready = false
    end
end)
0
The 'hit' parameter is nil. That means that whatever is firing the event isn't providing a parameter. Check your script that fires the Fill Event. Crazycat4360 115 — 6y

1 answer

Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
6 years ago
Fill.OnServerEvent:connect(function(player, hit)
    warn(player.Name)
    local ready = false
    if hit and hit.Name == "DriveSeat" then -- added a 'if hit'
        warn("OK, working FAR")
        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 
            ready == false or hit.Fuel.Value > 9.99
        end
    end
end)
0
add the script that fires the remote hellmatic 1523 — 6y
Ad

Answer this question