I need help please help me

Can someone please tell me what I am missing or what I’m doing wrong I’ve tried everything to fix this error and it doesn’t go away

They’re underlined in red because the script doesn’t know what they mean. If they are variables, you’ll need to define them first before using them in your script. Variables are local.

2 Likes

you never defined key or car seat

1 Like

So it should be Local Key instead of If key or is If local key

1 Like

How would I define it the car seat

1 Like

do

local key = -- what key is
local carSeat = --What car seat it

1 Like

now I’m get an error on “then”

1 Like
    local key = "q" then
if script.Parent.Gear.Value == -1 then
	script.Parent.Gear.Value = -1
else
	script.Parent.Gear.Value = script.Parent.Gear.Value -1
	carSeat.Shift:Play()
end
	end

    if key == "e" then
if script.Parent.Gear.Value == 1 then
	script.Parent.Gear.Value = 1
else
	script.Parent.Gear.Value = script.Parent.Gear.Value +1
	carSeat.Shift:Play()
end

end

1 Like

well the -- parts are where you would define what key or carSeat are like script.Parent.Seat

1 Like
    local key = "q" then
if script.Parent.Gear.Value == -1 then
	script.Parent.Gear.Value = -1
else
	script.Parent.Gear.Value = script.Parent.Gear.Value -1
	carSeat.Shift:Play()
end
	end

    if key == "e" then
if script.Parent.Gear.Value == 1 then
	script.Parent.Gear.Value = 1
else
	script.Parent.Gear.Value = script.Parent.Gear.Value +1
	carSeat.Shift:Play()
end

end

can i get the whole script? and a screen shot of the model

That is the whole script and I don’t know where the model is because I’m developing for someone

Oh well then ask them for a screen shot

You need to define key alone, not put it in an if statement.

For example:

local key = "q" -- this is a variable

if key == "q" then -- in this case, checking if the variable is true to its value
    -- code here
end
2 Likes

Ok I’ll try when I get back on Thank you do I do the same thing with the seat or?

the code you are using does not have a variable and i want to state some problems of your code

  • Use UserInputService to check if the player typed
  • Your variable Key doesn’t exist so the script wont recognize it neither
  • This should be a local script sending data to the server to fully prevent the exploiters, exploiting on it
  • If you set any value on the client it wont actually replicate to the server

Im sorry but how would this trigger when they hit q on their KeyBoard also you shouldn’t use strings use Enum.KeyCode.YOUR_KEY

you should probably use UserInputService with a remote event sending data to the server it would be more efficient then just setting everything up in the client