The loop is run on input began and input ended from a local script and it fires everytime the input begins and ends. When i end the input the loop doesnt end. What am i doing wrong?
if value == "IsCharging" then
track:Play()
repeat
char.Humanoid.Mana.Value = char.Humanoid.Mana.Value + 5
wait(.2)
until value == "IsNotCharging"
if value == "IsNotCharging" then
track:Stop()
end
end
end
end)
I can,t tell what u are doing wrong but have u try removing end and try to see if that work made i can,t tell i,m try to help but i can,t tell if that help than ok but if it on,t i don,t know what to do sorry.
so when a player holds a button it loops to give the player mana for as long as they held the button. also when i remove an end it has an error
wait i think u need to add more stuff to the script and the loops what is a mana i don,t know what is a mana and the loops i can fix that if is broke and by track player what do u mean by that i can tell u what u need to add to the script there are stuff masing i can try ok.
Where is the Value variable changed?
in a local script where it does the input began and input ended functions
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local RS = game.ReplicatedStorage
local Remote = RS.Charging
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
Remote:FireServer("IsCharging")
end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Q then
Remote:FireServer("IsNotCharging")
end
end)
Every time an event is fired, it creates a new connection. You might want to disconnect the connection on your event rather than while looping it.
Sorry im not very advanced with coding what does disconnecting the connection mean. This is the original script that one i posted above was modified.
local rs = game.ReplicatedStorage
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://7087173057"
rs.Charging.OnServerEvent:Connect(function(player, value)
if player.Skills:FindFirstChild("ManaChargeI") ~= nil then
local char = player.Character
local track = char:WaitForChild("Humanoid"):LoadAnimation(animation)
if value == "IsCharging" then
track:Play()
char.Humanoid.Mana.Value = char.Humanoid.Mana.Value + 1
end
if value == "IsNotCharging" then
track:Stop()
end
end
end)
Is the script a server script?
Where’s the value variable?
Make a repeat loop instead of checking if value is charging or not.
repeat
track:Play()
–other stuff
until value == “IsNotCharging”
Sorry for not telling you this earlier but i already figured it out
I am still glad you found out man!