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.
you never defined key or car seat
So it should be Local Key instead of If key or is If local key
How would I define it the car seat
do
local key = -- what key is
local carSeat = --What car seat it
now I’m get an error on “then”
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
well the --
parts are where you would define what key or carSeat are like script.Parent.Seat
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
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