You can write your topic however you want, but you need to answer these questions:
I want to make a stamina bar GUI and when I attempt to merge both of them in one script it breaks
This is my stamina script it builds up speed:
local UIS = game:GetService("UserInputService")
local TS = game:GetService("TweenService")
local plr = game.Players.LocalPlayer
UIS.InputBegan:Connect(function(key) --
if key.KeyCode == Enum.KeyCode.LeftShift or key.KeyCode == Enum.KeyCode.RightShift then
TS:Create(plr.Character.Humanoid, TweenInfo.new(2), {WalkSpeed = 23}):Play()
end
end)
UIS.InputEnded:Connect(function(key) --
if key.KeyCode == Enum.KeyCode.LeftShift or key.KeyCode == Enum.KeyCode.RightShift then
TS:Create(plr.Character.Humanoid, TweenInfo.new(2), {WalkSpeed = 16}):Play()
end
end)
Here is a screenshot of stamina GUI when I play the game it doesn’t move
I’ve tried to search up the solution on Youtube I also tried reading some articles on the Developer Hub but I had no luck
I tested and it works.
Where did you place this script?
You should place LocalScripts inside services like StarterGui, StarterPack or StarterPlayerScripts (StarterPlayerScripts is inside StarterPlayer).
Well, there isn’t really any problem since the script works (works as in it does everything you wrote inside of it) but it just hasn’t been given any instructions to change the stamina bar in that script you showed.
If you’re attempting to merge a server script & a local script then you won’t be able to, instead you’ll need to make use of RemoteEvents to allow for the client to communicate with the server and vice versa.
local UIS = game:GetService("UserInputService")
local TS = game:GetService("TweenService")
local plr = game.Players.LocalPlayer
UIS.InputBegan:Connect(function(key) --
if key.KeyCode == Enum.KeyCode.LeftShift or key.KeyCode == Enum.KeyCode.RightShift then
TS:Create(plr.Character.Humanoid, TweenInfo.new(2), {WalkSpeed = 23}):Play()
end
end)
UIS.InputEnded:Connect(function(key) --
if key.KeyCode == Enum.KeyCode.LeftShift or key.KeyCode == Enum.KeyCode.RightShift then
TS:Create(plr.Character.Humanoid, TweenInfo.new(2), {WalkSpeed = 16}):Play()
end
end)