|
| 20 Aug 2016 12:48 AM |
Non FM, completely made by me, thanks for the help.
Player = game.Players.LocalPlayer Mouse = Player:GetMouse() z = Player.Character a = z:FindFirstChild("Beyblade") g = a.Control function PressF(key) if (key == "w") then running = true local keyConnection = Mouse.KeyUp:connect(function (key) if (key == "w") then running = false end end)
elseif (key == "s") then running2 = true local keyConnection = Mouse.KeyUp:connect(function (key) if (key == "s") then running2 = false end end)
elseif (key == "a") then running3 = true local keyConnection = Mouse.KeyUp:connect(function (key) if (key == "a") then running3 = false end end)
elseif (key == "d") then running4 = true local keyConnection = Mouse.KeyUp:connect(function (key) if (key == "d") then running4 = false end end) end
while wait() do if running == true then g.Velocity2.Velocity = g.CFrame.lookVector*-5 elseif running == false then g.Velocity2.Velocity = g.CFrame.lookVector*0 end if running2 == true then g.Velocity2.Velocity = g.CFrame.lookVector*5 end if running3 == true then g.Turn.AngularVelocity = Vector3.new(0,2.5,0) end if running4 == true then g.Turn.AngularVelocity = Vector3.new(0,-2.5,0) end if running4 == false and running3 == false then g.Turn.AngularVelocity = Vector3.new(0,0,0) end end end
Mouse.KeyDown:connect(PressF) |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2016 12:52 AM |
| ima try removing the while loop then give results as to whether it delagged or if the script broke or watever. Ik that i put the while loop for a reason but idk if its actually need. We'll see ig |
|
|
| Report Abuse |
|
|
Ultraw
|
  |
| Joined: 20 Nov 2010 |
| Total Posts: 6575 |
|
|
| 20 Aug 2016 12:53 AM |
Heres what you should do
1. make the main velocity bit into a function, not a loop. 2. put all the KeyDown events into the same function 3. put all the KeyUp events into the same function 4. whenever any important keys are pressed, update the velocity using the function.
If you scripted it yourself then you should be able to manage that |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2016 12:55 AM |
Now I remember why I had the while loop. Can't get rid of that cus if I do then it gets rid of the turning while already moving.
Ex, the bey still rotates, but it doesnt affect the velocity until after the velocity was halted, then it turns towards the current face when W or S is pressed.
so gotta keep while |
|
|
| Report Abuse |
|
|
Ultraw
|
  |
| Joined: 20 Nov 2010 |
| Total Posts: 6575 |
|
|
| 20 Aug 2016 12:58 AM |
Do it like this:
function updateVelocity()
end
player = game.Players.LocalPlayer mouse = player:GetMouse()
mouse.KeyDown:connect(function(key) if key=="a" then updateVelocity() end end) |
|
|
| Report Abuse |
|
|
llaserx
|
  |
| Joined: 10 Dec 2011 |
| Total Posts: 53069 |
|
|
| 20 Aug 2016 01:10 AM |
Why are u using keydown Use userinputserivce |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2016 01:10 AM |
Wouldn't that still result in the Velocity being Set and the turning being unable to affect the Velocity's aim?
Ex.
functon update() if Velocityy == true then g.Velocity2.Velocity = g.CFrame.lookVector*-5 else if Velocityy == false then (if it were keyup) g.Velocity2.Velocity = g.CFrame.lookVector*0 end end if TURN == true --Updating turn.., not gunna copy and paste lol-- else if TURN == false then --no more turn-- end end end
function onkeydown() if key == blalaalalallalalala then Velocityy = true update() end if key == akdsjas then TURN = true update() end end
therefor the end result is a brick moving at its former velocity aimpoint of -5 and a rotation that doesn't reset the velocity's set movement line.?
Unless I were to do a update for the 'Turn' and 'Velocityy' but that would most likely only occur once per keydown/keyup and not work like a loop would. |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2016 01:14 AM |
If you didn't understand what I ment about updates and velocity vs gyro(rotating/turning)
think of it like Ticks
Onkeydown = 1 tick onkeyup = 1 tick
that means if it were to update the entire list of controls for velocity(Velocityy = false) and gyro(TURN = false) then it'd only do that once per keydown/keyup cus it only grants 1 tick.
but if it were a while wait() do loop # tick --the hashtag is ment to resemble a number sign
while wait() do # tick(s) update() end
the amount of ticks is constantly going, meaning that the update is being constantly updated. |
|
|
| Report Abuse |
|
|
Ultraw
|
  |
| Joined: 20 Nov 2010 |
| Total Posts: 6575 |
|
|
| 20 Aug 2016 01:16 AM |
Oh yeah
I see
it uses the CFrame of g |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2016 01:17 AM |
If you think you know the solution to it fully, cus i tried doing what you said already and it did what it did the first time when I did the functioning differently, it'd mean a lot to me if you could put it together yourself because i have to be up really early and ima be gone all day, but also i don't want to spend too much time trying to completely understand anything i dont already know or understand that you potentially state because i'm hired rn by a famous game dev and i can't be taking too long with 1 script.
|
|
|
| Report Abuse |
|
|
|
| 20 Aug 2016 01:20 AM |
Thanks in advance, even if you don't end up doing it.
|
|
|
| Report Abuse |
|
|
Ultraw
|
  |
| Joined: 20 Nov 2010 |
| Total Posts: 6575 |
|
|
| 20 Aug 2016 01:21 AM |
What are you using? BodyVelocity?
I think there might be a bodymover which moves something relative to itself. I'm not sure though. I don't really use them
|
|
|
| Report Abuse |
|
|
Ultraw
|
  |
| Joined: 20 Nov 2010 |
| Total Posts: 6575 |
|
|
| 20 Aug 2016 01:22 AM |
And, no. I'm not doing it for you sorry
someone else might |
|
|
| Report Abuse |
|
|
OzzyFin
|
  |
| Joined: 07 Jun 2011 |
| Total Posts: 3600 |
|
|
| 20 Aug 2016 01:40 AM |
"i'm hired rn by a famous game dev"
he did the worst possible choice, I feel bad for him please, before you ever start making robux out of scripting learn the language first
Now to your actual problem:
You're connecting 4 events everytime any key is pressed AND starting an infinite loop. Also as an already mentioned side note, which you totally ignored, you're using deprecated methods and should change to UserInputService.
I wrote this on my phone, expect there to be syntax/simple logical errors the while loop is the same however.
local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:wait()
local a = Character:WaitForChild("Beyblade") local g = a:WaitForChild("Control")
local UIS = game:GetService("UserInputService")
local states = { W = false, A = false, S = false, D = false, }
UIS.InputBegan:connect(function(input,gpe) if not gpe then if states[input.KeyCode.Name] then states[input.KeyCode.Name] = not states[input.KeyCode.Name] end end end)
while wait() do -- I don't exactly know what you're doing, so I'll just expect this to be the best method if states.W == true then g.Velocity2.Velocity = g.CFrame.lookVector*-5 elseif states.W == false then g.Velocity2.Velocity = g.CFrame.lookVector*0 end if states.A == true then g.Velocity2.Velocity = g.CFrame.lookVector*5 end if states.S == true then g.Turn.AngularVelocity = Vector3.new(0,2.5,0) end if states.D == true then g.Turn.AngularVelocity = Vector3.new(0,-2.5,0) end if states.D == false and states.S == false then g.Turn.AngularVelocity = Vector3.new(0,0,0) end end end |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2016 09:56 PM |
Already made over 800k and had a semi famous game series, I can script a lot of things but that doesn't mean I know every avenue of the language. You can't expect someone to know how to do literally anything and everything in a language as wide as this, for example, a foreigner who learned english for 6 years would know how to use a lot of it properly but would still have trouble with some words or sentence structure.
You really shouldn't bash on others skills if you yourself are some scripting overlord, when you have nothing to show for it.
@ozzy
:) |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2016 09:58 PM |
| But still a thanks for the help. |
|
|
| Report Abuse |
|
|
|
| 20 Aug 2016 10:17 PM |
Well, after testing your version of the script out, it didn't turn out good.
As I said earlier, the ticking needs to update, and with this script it doesn't update, in fact it does worse than what my previous pure function version did.
It gets stuck turning, it goes forward until you press W again (so its Ticks don't update), and it doesn't work well with opposing forces (Ex, if I pressed W I can't press S anymore, or if I press S I can't press W anymore).
Not sure if this is due to a mess up on your part or if this way just doesn't work good.
And btw, my current version works perfectly, it just has lag (not even sure if it is the direct source or not, but it definitely contributes to the lag a tiny bit).
Never saw a reason for you to be rude in the first place, but if you'll be rude I will be rude back ig, especially after you insulted my abilities based off of a script in a criteria I have never worked in before, then your script does worse than mine. |
|
|
| Report Abuse |
|
|
Nineheroz
|
  |
| Joined: 23 May 2015 |
| Total Posts: 450 |
|
|
| 20 Aug 2016 10:21 PM |
Use the Script Minifier plug-in, it should be in my inventory.
|
|
|
| Report Abuse |
|
|
|
| 20 Aug 2016 10:48 PM |
| Sounds cool, thanks for the recommendation! |
|
|
| Report Abuse |
|
|
OzzyFin
|
  |
| Joined: 07 Jun 2011 |
| Total Posts: 3600 |
|
|
| 21 Aug 2016 01:34 AM |
I missed an important part due to lack of identation which I'm not blaming you, but rather ROBLOX for having such a poor support for it. That also makes my statement of you connecting 4 KeyUp events everytime you press a button incorrect, the while loop stands however and is the cause of the lag.
UIS.InputBegan:connect(function(input,gpe) if not gpe then if states[input.KeyCode.Name] then states[input.KeyCode.Name] = true end end end)
UIS.InputEnded:connect(function(input,gpe) if not gpe then if states[input.KeyCode.Name] then states[input.KeyCode.Name] = false end end end)
Manipulating the BodyMover is just one part of the script. I understand if you have never worked on them but that shouldn't make your whole code inefficient, ugly and overall just bad.
I mentioned for a reason there might be logical errors that you should be able to correct yourself. I'm not sure if the above fix will do it because I can't really test it for you and if it doesn't try to move the while loop out of the 'PressF' function's scope. Again, most likely the lag from the original code (expecting that's the full code) comes from the stacking while loops. You're calling the PressF function everytime someone presses ANY key on their keyboard and what the function does is creates a new infinite while loop.
I rewrote the script so you would see how it could be done more organized and efficient that doesn't mean you need to use it, but should.
Being successfull and a good scripter are two different things. I don't care how much you've made money nor about your games until they were done quality over quantity in mind (which I doubt) and have brung something new and beautiful to ROBLOX (probably every dev will say that about their games but I judge that by myself). You might have better marketing skills, better contacts & builders and more motivation than I do which allows you to create a bunch of money. I am more of a solo developer who is not creative at all so I haven't really succeeded especially building wise. |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2016 01:36 AM |
lmao this guy literally made like 20 keybinds
also dont use keydown and keyup
user input service is 1000000000x better |
|
|
| Report Abuse |
|
|
llaserx
|
  |
| Joined: 10 Dec 2011 |
| Total Posts: 53069 |
|
|
| 21 Aug 2016 01:37 AM |
U made a semi famous game and using a depricated method
Lolwat |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2016 02:44 AM |
- I solo dev'd until this summer, now I work with another game dev who specializes in Building and Graphics (GFX, Texturing, Custom Meshes).
- I have games that I really don't think you could solo dev, with your 'Laziness'.
- The games on my profile are about a 1/10 out of my max efforts.
- My 1/10 got those visits without ever advertising, and was solo dev'd.
- I have a game i'm making and have been making that is in the same exact level of ExohdaCody's Medieval Reforge, and is a spinoff of his version, but with different capabilities and different items, map, and gameplay.
- I have a game i'm making that is currently either slightly worse or near on-par with Shard Online on Building, scripting, and greater than Shard on Animations since they leave out so many animations for some mobs, yet they still have better GFX and Sound since their sounds are custom made directly for them whereas mine are made by a user who makes his free to public, but still custom makes them.
- I specialize In NPCs Building, NPC Animating, and very much in NPC Scripting. I also do Maps, Details, Effects, GUI scripting and Creating, Retexturing, Universal features, Ex. Friend Teleport, Squad Teleport, Clans, and Chatboard/Recommended Updates from user response. I also have entire 'packages' of Inventory System + Crafting, Dropping, Picking up, Trading, Player Inspection, leaderboard, and more.
- I've probably made games solo with 4/10 effort better than your best game rn.
Just because you know how to use more things throughout coding doesn't mean that your games are by default better and smoother than mine, and if you think so, go ahead and make a game.
--My solo games will be out in 1-2 months possibly, depending on IRL delays and other team-deving delays, so you'll have to wait for them to come. That should give you plenty of time to make your own game, but I doubt you'll make it anywhere near their level.
If you talk trash and can't do anything yourself, then don't talk trash. If you don't make a game that's atleast on a scale of 7/10 of my max effort then, well, that's a shame, but since you're such an almighty overlord in scripting with lua, this shouldn't be that hard.
-Best regards, ~the person you randomly insulted on the forums who now holds you to this since you like to attempt superiority over others-
Don't let me down.
--HAS TO BE SOLO DEV'D, NO FMS ALLOWED, Only things allows: Free Images, Free Sound, items made by yourself--.
This isn't a competition, it's just a way of getting you to back up your boasts, even if they aren't direct boasts like 'I'm the best scripter', but rather ("i'm hired rn by a famous game dev" he did the worst possible choice, I feel bad for him please, before you ever start making robux out of scripting learn the language first") A faint trail of superiority hides behind this wall of bloat and insult.
:)
|
|
|
| Report Abuse |
|
|
OzzyFin
|
  |
| Joined: 07 Jun 2011 |
| Total Posts: 3600 |
|
|
| 21 Aug 2016 02:57 AM |
LOL Your ego is huge.
I clearly stated why you've made games and I have not and you go absolutely crazy about what I've said. I don't think I have insulted you at all especially in my last post.
I have no interest in your bad quality front page games.
Oh and thanks for the laughs, that was hilarious to read just shows what an ass you are. |
|
|
| Report Abuse |
|
|
llaserx
|
  |
| Joined: 10 Dec 2011 |
| Total Posts: 53069 |
|
|
| 21 Aug 2016 03:05 AM |
I used a non depreicTed method
I think i already past u :3333333
And sir i have 0 games on my profiles Only sandboxes |
|
|
| Report Abuse |
|
|