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

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

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)

1 comment

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.

1 answer

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)

1 comment

0

add the script that fires the remote

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