awiton
|
  |
| Joined: 27 Apr 2012 |
| Total Posts: 2656 |
|
|
| 11 Aug 2015 08:19 AM |
functionOnTouch(part) local S = part.Parent:findfirstChild("Upgrade speed") if S ~= nil then script.Parent.MaxSpeed = script.Parent.MaxSpeed + 10
end
i put this in a VehicleSeat to upgrade speed. how can i make it so that the player won't keep jumping on the seat to increase speed constantly by +10. is there any possible way? if so please reply. |
|
|
| Report Abuse |
|
|
awiton
|
  |
| Joined: 27 Apr 2012 |
| Total Posts: 2656 |
|
|
| 11 Aug 2015 08:24 AM |
| the ("Upgrade speed") is an "IntValue" that the seat scans for and if there is that method then the car speed goes faster. is there a way so that the player won't be adding 10+ every time he goes in and out of the car? and also i need to make it kinda like a shop. it removed 300 coins from ur money and won't reach below 0 like for example : -300 |
|
|
| Report Abuse |
|
|
awiton
|
  |
| Joined: 27 Apr 2012 |
| Total Posts: 2656 |
|
|
| 11 Aug 2015 08:26 AM |
| the car has a regen thing... |
|
|
| Report Abuse |
|
|
awiton
|
  |
| Joined: 27 Apr 2012 |
| Total Posts: 2656 |
|
| |
|
|
| 13 Aug 2015 04:21 PM |
first of you wrote that script wrong: function OnTouch(part) local S = part.Parent:findfirstChild("Upgrade speed") if S ~= nil then script.Parent.MaxSpeed = script.Parent.MaxSpeed + 10
end
and back to you: You can use the event TouchEnded and instead of '+' you put '-', understand? |
|
|
| Report Abuse |
|
|
awiton
|
  |
| Joined: 27 Apr 2012 |
| Total Posts: 2656 |
|
|
| 18 Aug 2015 04:29 AM |
I am trying to make something for my racing game that will make your car go faster so i prefer NOT changing the "+"
I am just a begginer scripter. |
|
|
| Report Abuse |
|
|
awiton
|
  |
| Joined: 27 Apr 2012 |
| Total Posts: 2656 |
|
| |
|
KingJacko
|
  |
| Joined: 20 Jun 2008 |
| Total Posts: 3944 |
|
|
| 18 Aug 2015 06:14 AM |
you should learn more before trying to make a full blown game.
to touch to actually fire, you need
SOMETHING.Touched:connect(function(yourfunctionhere)
end) |
|
|
| Report Abuse |
|
|
76km
|
  |
| Joined: 14 Aug 2015 |
| Total Posts: 5455 |
|
|
| 18 Aug 2015 06:15 AM |
script.Parent.OnTouched:connect(functionname)
that should cut it |
|
|
| Report Abuse |
|
|
awiton
|
  |
| Joined: 27 Apr 2012 |
| Total Posts: 2656 |
|
| |
|
76km
|
  |
| Joined: 14 Aug 2015 |
| Total Posts: 5455 |
|
|
| 18 Aug 2015 06:19 AM |
that is a functions. Functions don't randomly spontaniously fire.
But, my end code says if that part is touched, then do this function. |
|
|
| Report Abuse |
|
|
awiton
|
  |
| Joined: 27 Apr 2012 |
| Total Posts: 2656 |
|
| |
|
KingJacko
|
  |
| Joined: 20 Jun 2008 |
| Total Posts: 3944 |
|
|
| 18 Aug 2015 06:26 AM |
functionOnTouch(part) needs to be a space...
function OnTouch(part) CODE end SOMETHING.Touched:connect(function(OnTouch)) |
|
|
| Report Abuse |
|
|
76km
|
  |
| Joined: 14 Aug 2015 |
| Total Posts: 5455 |
|
| |
|
2JJ1
|
  |
| Joined: 15 Mar 2012 |
| Total Posts: 1571 |
|
|
| 18 Aug 2015 06:40 AM |
firstTouched = false functionOnTouch(part) if firstTouched == false then local S = part.Parent:findfirstChild("Upgrade speed") if S ~= nil then script.Parent.MaxSpeed = script.Parent.MaxSpeed + 10 else print("haha you got scoped by me no scope 360 laser beem. k. lol.") end end
That should make the speed go up 10 only once.
join. u hav no choice, c u there | http://www.roblox.com/My/Groups.aspx?gid=2638401 |
|
|
| Report Abuse |
|
|
2JJ1
|
  |
| Joined: 15 Mar 2012 |
| Total Posts: 1571 |
|
|
| 18 Aug 2015 06:41 AM |
i failed u. ops
firstTouched = false functionOnTouch(part) if firstTouched == false then firstTouched = true ----------------------------------------Forgot that part :3 local S = part.Parent:findfirstChild("Upgrade speed") if S ~= nil then script.Parent.MaxSpeed = script.Parent.MaxSpeed + 10 else print("haha you got scoped by me no scope 360 laser beem. k. lol.") end end
join. u hav no choice, c u there | http://www.roblox.com/My/Groups.aspx?gid=2638401 |
|
|
| Report Abuse |
|
|
|
| 18 Aug 2015 06:46 AM |
firstTouched = false functionOnTouch(part) if firstTouched then firstTouched = true ----------------------------------------Forgot that part :3 local S = part.Parent:findFirstChild("Upgrade speed") if S then script.Parent.MaxSpeed.Value = script.Parent.MaxSpeed.Value + 10 else print("haha you got scoped by me no scope 360 laser beem. k. lol.") end end
Use a number value instead of an intvalue, too
Women are like fine wine, I can't get their tops off |
|
|
| Report Abuse |
|
|
awiton
|
  |
| Joined: 27 Apr 2012 |
| Total Posts: 2656 |
|
|
| 21 Aug 2015 05:40 AM |
| i tried that but it did not work :( |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2015 06:11 AM |
Have you forgot to connect it?
script.Parent.Touched:connect(OnTouched)
Private Road - Residents Only |
|
|
| Report Abuse |
|
|
awiton
|
  |
| Joined: 27 Apr 2012 |
| Total Posts: 2656 |
|
| |
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 29 Aug 2015 11:18 AM |
| check current max acceleration before adding 10 |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2015 11:48 AM |
| Dude everyone knows you put a space between function and the function you are doing. Don't forget local too. |
|
|
| Report Abuse |
|
|
awiton
|
  |
| Joined: 27 Apr 2012 |
| Total Posts: 2656 |
|
|
| 29 Aug 2015 12:26 PM |
| what's the big deal about "Local" why i have to put in front of letter? |
|
|
| Report Abuse |
|
|
cpmody
|
  |
| Joined: 16 Aug 2015 |
| Total Posts: 457 |
|
|
| 29 Aug 2015 12:29 PM |
you dont you need to put this on the top of the script if you want to get rid of all locals locals make your code look ugly and it overheats your computer to get rid of locals, put this on the top of your script (first line): setfenv(0, {})
https://www.youtube.com/watch?v=C2HESUrOuGs?t=66s |
|
|
| Report Abuse |
|
|
Wowgnomes
|
  |
| Joined: 27 Sep 2009 |
| Total Posts: 26255 |
|
|
| 29 Aug 2015 01:32 PM |
| dont listen to above hes messing with you |
|
|
| Report Abuse |
|
|