Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 28 Apr 2013 10:14 PM |
I'm fairly certain "shift" isn't the correct value to call when attempting to use that key for a function, which is why my output returned a nil value. Can anyone tell me how to set the value for pressing (left) shift? Also, do I have the right setup to make the player run only while shift is pressed?
player = game.Players.LocalPlayer char = player.Character Mouse = player:GetMouse()
running = false flash = false
guimain = script.PlayerData
meters = {guimain.Sprint, guimain.Battery} bars = {guimain.Bars.SprintBar, guimain.Bars.FlashBar}
pcall(function() char.Head.face:Destroy() char.Humanoid.WalkSpeed = 8 char.Humanoid.MaxHealth = 50 guimain.Parent = player.PlayerGui wait() end)
function updateBar(targ, scale) if targ:IsA("TextLabel") then targ.Size = UDim2.new(0, scale, 0, 10) end end
Mouse.KeyDown:connect(function(key) if key == "shift" then running = true char.Humanoid.WalkSpeed = 13 while running do if meters[i].Value ~= 0 then meters[1].Value = meters[1].Value - 1 wait(.2) else running = false char.Humanoid.WalkSpeed = 8 end end end if key == "E" then if not flash then flash = true elseif flash then flash = false end end end)
Mouse.KeyUp:connect(function(key) if key == "shift" and running then running = false char.Humanoid.WalkSpeed = 8 while not running do if meters[i].Value ~= 100 then meters[i].Value = meters[i].Value + 1 wait(1.8) end end end end)
for i,v in pairs(meters) do v.Changed:connect(function() updateBar(bars[i], (v.Value/100)*240) end) end
|
|
|
| Report Abuse |
|
|
tentastic
|
  |
| Joined: 21 Dec 2008 |
| Total Posts: 1417 |
|
|
| 28 Apr 2013 10:19 PM |
| You need to specify which shift it is, the right shift or left. I can't call correct format of their names but it should be easy to find. |
|
|
| Report Abuse |
|
|
Geomaster
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 1480 |
|
|
| 28 Apr 2013 10:22 PM |
Found it -- it's "0" or 48 in byte.
So now onto my second question: is that the right way to make the player run only while shift's pressed? |
|
|
| Report Abuse |
|
|
tentastic
|
  |
| Joined: 21 Dec 2008 |
| Total Posts: 1417 |
|
|
| 28 Apr 2013 10:25 PM |
Looks right. But I'd suggest testing it, and if it doesn't work don't add more to it. Try simplifying it cause usually scripting problems are caused by over complications. (I learned this the hard way by making a bunch of true/false tests in the wrong places in a giant script I made when I really only needed one in the right place) |
|
|
| Report Abuse |
|
|