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

Why isn't this script working?

Asked by 10 years ago

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

Log in to vote
0
Answered by 10 years ago

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)
Ad
Log in to vote
0
Answered by 10 years ago

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)

Answer this question