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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Stamina/Run

Previous Thread :: Next Thread 
TorvaDragon is not online. TorvaDragon
Joined: 20 May 2014
Total Posts: 220
01 Sep 2014 11:03 PM
I made two simple scripts and I need help turning them into an expert script.
So basically I made a run script to where you press down shift to run, I also made a gui/script for stamina but it's not connected. The stamina script/gui is connected to a button that you click once to run and the stamina will slowly go down. Anyways I want to connect these two scripts to where the stamina goes down when you run with shift instead of the button.


Shift run script:
wait()local Player=game.Players.LocalPlayer local Mouse = Player:GetMouse()
local Speed = 35
local Humanoid = Player.Character:WaitForChild("Humanoid")
local OrigSpeed = Humanoid.WalkSpeed


Mouse.KeyDown:connect(function(Key)local Code=Key:byte()if(Code==48)then Humanoid.WalkSpeed = Speed end end)
Mouse.KeyUp:connect(function(Key)local Code=Key:byte()if(Code==48)then Humanoid.WalkSpeed = OrigSpeed end end)



Stamina script:
run = script.Parent.Running
stam = script.Parent.Stamina
maxstam = stam.Value
frame = script.Parent.Frame
bar = frame.Bar
runb = script.Parent.Run
reset = script.Parent.Reset
plr = script.Parent.Parent.Parent
usespeed = 5
regainspeed = 5

reset.MouseButton1Click:connect(function(mouse)
pcall(function()
plr.Character:BreakJoints()
end) end)

runb.MouseButton1Click:connect(function(mouse)
pcall(function()
if run.Value == true then
run.Value = false
elseif run.Value == false then
if stam.Value > 0 then
run.Value = true
plr.Character.Humanoid.WalkSpeed = 35
else
plr.Character.Humanoid.WalkSpeed = 16
end end end) end)

while true do
wait()
if run.Value == true then
plr.Character.Humanoid.WalkSpeed = 35
if stam.Value <= 0 then run.Value = false end
stam.Value = stam.Value - maxstam/(usespeed*200)
bar.Size = bar.Size - UDim2.new(1/(usespeed*200),0,0,0)
elseif run.Value == false then
if stam.Value < maxstam then
plr.Character.Humanoid.WalkSpeed = 16
stam.Value = stam.Value + maxstam/(regainspeed*200)
bar.Size = bar.Size + UDim2.new(1/(regainspeed*200),0,0,0)
end end end
Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
01 Sep 2014 11:04 PM
i smell freemodel
Report Abuse
BothAngles is not online. BothAngles
Joined: 01 Dec 2011
Total Posts: 9604
01 Sep 2014 11:06 PM
free models
Report Abuse
Subete is not online. Subete
Joined: 10 Jul 2011
Total Posts: 917
01 Sep 2014 11:06 PM
if he could script that but doesn't know how to connect them


100% free model

but i dont judge
Report Abuse
TorvaDragon is not online. TorvaDragon
Joined: 20 May 2014
Total Posts: 220
01 Sep 2014 11:10 PM
Those are simple scripts.. Even a toddler could write them, how are they free models? Go ahead and try to find the exact same script. Anyways combining them is a hard process
Report Abuse
CrowClaws is not online. CrowClaws
Joined: 04 Jul 2010
Total Posts: 4466
01 Sep 2014 11:48 PM
Well.
If you know how to script that.
You could do it.

If it's freemodels just say it.
Report Abuse
TorvaDragon is not online. TorvaDragon
Joined: 20 May 2014
Total Posts: 220
01 Sep 2014 11:52 PM
I always say when I use free models (Credit the owner) Combining these scripts is just difficult for me, apparently you people find it weird that I can script those scripts but I cant combine them but I think that's perfectly normal for a intermediate scripter
Report Abuse
TorvaDragon is not online. TorvaDragon
Joined: 20 May 2014
Total Posts: 220
02 Sep 2014 12:03 AM
Because I cant combine them*
Report Abuse
CrescentJade is not online. CrescentJade
Joined: 07 Jul 2010
Total Posts: 5494
02 Sep 2014 03:39 AM
.-.

this is what I did

running/refill
------

wait(1)

on = false

plr = game.Players.LocalPlayer
cam = game.Workspace.CurrentCamera
arm1 = plr.Character.Torso["Right Shoulder"]
arm2 = plr.Character.Torso["Left Shoulder"]

m = plr:GetMouse()

m.KeyDown:connect(function(key)
if not on then
if key:lower() == "q" then
if plr.PlayerGui.Bars.Stamina.Frame.LocalScript.POP.Value >=20 then
if not on then
on = true
plr.Character.Humanoid.WalkSpeed = 30
plr.PlayerGui.Bars.Stamina.Frame.LocalScript.POP.Value = plr.PlayerGui.Bars.Stamina.Frame.LocalScript.POP.Value - 20
wait(4)
plr.Character.Humanoid.WalkSpeed = 16
wait(1)
on = false
end
end
end
end
end)

function lol()
for i = 1,math.floor(plr.PlayerGui.Bars.Stamina.Frame.LocalScript.POP.Value/4,.5) do
wait(0)
if plr.PlayerGui.Bars.Stamina.Frame.LocalScript.POP.Value ~= plr.PlayerGui.Bars.Stamina.Frame.LocalScript.CORN.Value then
plr.PlayerGui.Bars.Stamina.Frame.LocalScript.POP.Value = plr.PlayerGui.Bars.Stamina.Frame.LocalScript.POP.Value + 1
else
end
end
end

while wait(10) do
lol()
end

--stamina--

wait(0)

val = script.POP
maxval = script.CORN

while true do
wait(0.1)
local pie = ( val.Value / (maxval.Value))
script.Parent.Size = UDim2.new( pie , 0 , 0, 20)
end
Report Abuse
CrescentJade is not online. CrescentJade
Joined: 07 Jul 2010
Total Posts: 5494
02 Sep 2014 03:41 AM
Stamina/Health/Exp, etc. bars are easy to make btw..
Report Abuse
TorvaDragon is not online. TorvaDragon
Joined: 20 May 2014
Total Posts: 220
02 Sep 2014 11:33 AM
Yeah I can work on thos myself, thanks thought :)
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