generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: 'end' expected (to close 'function' at line 2 near 'elseif'

Previous Thread :: Next Thread 
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
08 May 2014 04:27 PM
script.Parent.ChildAdded("SeatWeld")
function onKeyDown( e )
script.Parent.Parent.EngineRunning = true
script.Parent.CarStartSound:Play() elseif
script.Parent.ChildRemoved("SeatWeld") then
return nil
end

mouse.onKeyDown:connect(onKeyDown)
Report Abuse
robomax11 is not online. robomax11
Joined: 07 Jul 2011
Total Posts: 6828
08 May 2014 04:29 PM
please, learn how to script. if this is troll u won

im going upstairs to get somehting downstairs
Report Abuse
VerifiedName is not online. VerifiedName
Joined: 26 Jul 2009
Total Posts: 4534
08 May 2014 04:30 PM
op, i think you need to revisit the basics.

Report Abuse
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
08 May 2014 04:39 PM
Revisit for a looong time
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
08 May 2014 04:47 PM
and wat did I do wrong??? am sure I did lots wrong, but wat??? and how to fix???
Report Abuse
powertool is not online. powertool
Joined: 01 Feb 2008
Total Posts: 3771
08 May 2014 04:52 PM
MY EYES BLEED.

mouse.KeyDown:connect(function(key)
repeat wait() until script.Parent.ChildAdded("SeatWeld") --Too lazy to do this in a better way.
if key == "e" then
if script.Parent.Parent.EngineRunning ~= true then
script.Parent.Parent.EngineRunning = true end
script.Parent.CarStartSound:Play()
if 1+1 ~= 2 then return end --Learn to math.
end
end)
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
08 May 2014 04:59 PM
but does it fully do wat I want? cos I want it to be like that if ur sitting in the seat and press E and then EngineStart Value is turned to true from false (cos I see u said 'if Value == true then Value = true end' and the Sound is played, and then I anna add a thing that if u press E again then it shuts ur engine down (puts Value as false) and then plays the shutdown sound (gonna add it)... anyways, at least someone helped :D
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
08 May 2014 05:24 PM
I try press e and nothing happens, I cant drive, nor is there a sound
Report Abuse
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
08 May 2014 06:10 PM
Kapit, go learn the basics. You barely understand a thing
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
08 May 2014 06:12 PM
dude... I did... and 1 example in the basics I saw was 'onKeyDown == ( keyhere )' so that was wrong, anything else wrong might as well be the same... and anyways, I gotta make a start! am not ust gonna sit there in a boring thing readin wen i can make my own and learn from my mistakes as I go...
Report Abuse
zakarq is not online. zakarq
Joined: 10 Oct 2010
Total Posts: 883
08 May 2014 06:19 PM
What you need to revisit is the Roblox Wiki.
Report Abuse
TehIcyStar is not online. TehIcyStar
Joined: 07 Mar 2010
Total Posts: 1649
08 May 2014 06:21 PM
^

yeah, when I started, I didn't start with keydown stuff.

I started with printing, then moved to ifs, functions and so forth. I bet you didn't even learn these things
Report Abuse
epicpatrick123 is not online. epicpatrick123
Joined: 08 Sep 2010
Total Posts: 15039
08 May 2014 06:28 PM
r u serious
Report Abuse
ForeverDev is not online. ForeverDev
Joined: 04 Oct 2008
Total Posts: 13300
08 May 2014 07:22 PM
This HAS to be a troll...
Report Abuse
powertool is not online. powertool
Joined: 01 Feb 2008
Total Posts: 3771
09 May 2014 01:52 AM
KeyDown scripting is tricky and requires a tool or local script to get the mouse.

HOWEVER print("REVISIT SCRIPTING BASICS FIRST").
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
09 May 2014 03:48 AM
tehl, I did :P I did functions, print, keydownm leaderboards, and not in the scripting thing, I know wat all yas didnt look at! and thats y there are hardly any good cars on Roblox, only the designs are impressive, but not the persofrmance! so stop saying crap to me if yas havent read everything urselves!
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
09 May 2014 04:09 AM
Guys. You realize this is why everyone hates us? Your telling him comments like "learn to script" "this HAS to be a troll" and "revisit the basics"

We're ScriptingHelpers, and quite frankly, this isn't helping.


Now, on to OP. kapitanovas, I don't think you completely understand elseif. In order to use elseif you need an if. Also keydown works s bit differently... Try this;

script.Parent.ChildAdded("SeatWeld")

mouse.onKeyDown:connect(function(k) --On keydown, check what key was pressed and assign to k
if k:lower()=="e" and script.Parent.Parent.EngineRunning == false then --Check to see if e was pressed and the engine is off
script.Parent.Parent.EngineRunning = true --Start the engine
script.Parent.CarStopSound:Stop() --Stop if it is still going.
script.Parent.CarStartSound:Play() --Play
elseif k:lower()=="e" and script.Parent.Parent.EngineRunning == true then --Check if e was pressed and engine is on.
script.Parent.Parent.EngineRunning = false --Stop the engine
script.Parent.CarStartSound:Stop() --Stop if it is still going.
script.Parent.CarStopSound:Play() --Play
end --if/elseif/else require an end to close them


script.Parent.ChildRemoved("SeatWeld") --Can you please explain what your doing here?

end) --Functions also require an end. And the brack is to close the connection line.




There. I also seperate s two lines from the others asking what you were doing.
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
09 May 2014 04:11 AM
He learned it all wrong.

He must revisit basics or more probs will come.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
09 May 2014 04:12 AM
also if your going to use mouse.KeyDown() you have to be using a LocalScript and this gotta be the first line;

mouse = game.Players.LocalPlayer:GetMouse()
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
09 May 2014 04:13 AM
@vlek

I understand that. But maybe he had trouble with it. That doesn't give anybody the right to be mean to him.

Maybe he needs someone to help him learn. Ever think of that?
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
09 May 2014 04:13 AM
^ thats what i mean
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
09 May 2014 04:16 AM
I aint being mean,
And i ment your getmouse post.

If he needs help with understanding he has to come here,
and if he wants working scripts then he should learn basics with dedication and not only for the stuff you need.

Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
09 May 2014 04:25 AM
thnx a lot warspyking, thnx for standing up and also for helping out :D also, I wanted the ChildRemoved(SeatWeld) to not let the person to get the car running, so u have to be in the VehicleSeat to get the car running... u get me?
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
09 May 2014 04:26 AM
Vehicle speed = 0
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
09 May 2014 04:31 AM
Your welcome. So you want them to be sat when they do it. That is a bit more complicated and I have to go, I can help you later.

Also kap, incase you do wanna revisit the basics, I highly reccomend these guides;

http://www.roblox.com/Forum/ShowPost.aspx?PostID=133254933
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image