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

Why isn't this script working?

This is used when im in a car seat then fire comes out when i press e but it does work for some reason.

wait(0.1)
local player = game.Players.LocalPlayer
local HUB = script.Parent.HUB
local lightOn = false
local carSeat = script.Parent.CarSeat.Value
local limitButton = HUB.Limiter

mouse.KeyDown:connect(function (key)
    key = string.lower(key)
        if key == "e" then
		carSeat.Parent.Part1.backfire1.Enabled = false
		limited = false
	else	
		carSeat.Parent.Part1.backfire1.Enabled = true
		limited = true	
	end
end)

2 answers

1. Limited isn't a variable. 2. You said when you press ' e ' you want fire to come out. Well you have your true and false backwards. 3. The else statement isn't needed.

Here is the revised script:

wait(0.1)
local player = game.Players.LocalPlayer
local HUB = script.Parent.HUB
local lightOn = false
local carSeat = script.Parent.CarSeat.Value
local limitButton = HUB.Limiter
local limited=whatever_limited_is_supposed_to_be --CHANGE ME

mouse.KeyDown:connect(function (key)
    key = string.lower(key)
        if key == "e" then
        carSeat.Parent.Part1.backfire1.Enabled = true
        limited = true
	wait(1)
	carSeat.Parent.Part1.backfire1.Enabled=false 
    end
end)

You need to define "mouse" and "limited" also you had done the string.lower(key) done wrong. I have fixed this script and hope it works out for you!

wait(0.1)
local player = game.Players.LocalPlayer
local HUB = script.Parent.HUB
local lightOn = false
local carSeat = script.Parent.CarSeat.Value
local limitButton = HUB.Limiter
local mouse = player:GetMouse()
local limited = whateveryouwant

mouse.KeyDown:connect(function(key)
        if string.lower(key) == "e" then
        carSeat.Parent.Part1.backfire1.Enabled = false
        limited = false
    else    
        carSeat.Parent.Part1.backfire1.Enabled = true
        limited = true  
    end
end)

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