Hey, I’m having this REALLY bad issue here.
So basically; I made a tool keep going forward when you hold click but stop when you release mouse1 or the sound ends but even when the sound ends it just keeps on going.
Heres the tool I was making:
https://www.roblox.com/library/9366714228/Builder-Brothers-Pizza-Delivery
For some reason, it stops charging when the sound ends in studio, but not in-game. I’ve been using Kohls Admin gear command to give me the tool ingame.
If anyone can help, please and thank you.
local Services = {
RunService = game:GetService("RunService"),
TweenService = game:GetService("TweenService"),
Players = game:GetService("Players"),
}
local Create = function(ty)
return function(data)
local obj = Instance.new(ty)
for k, v in pairs(data) do
if type(k) == 'number' then
v.Parent = obj
else
obj[k] = v
end
end
return obj
end
end
local Tool = script.Parent
local Assets = Tool:WaitForChild("Assets",3)
local Configuration = Tool:WaitForChild("Configuration",3)
local Variables = {
Active = false,
Equipped = false,
Character = nil,
Player = nil,
Arm = nil,
OriginalC0 = nil,
C0 = nil,
GUI = nil,
Force = Create("BodyVelocity"){
MaxForce = Vector3.new(math.huge,0,math.huge)
},
ToolGrips = {
Active = CFrame.new(-0.0330870152, -0.156805992, -0.00628089905, -6.14787609e-07, -1, -4.14440429e-08, -3.13040914e-07, 4.14442347e-08, -1, 1, -6.14787609e-07, -3.13040943e-07),
Inactive = CFrame.new(-1.37223721, 0, -0.0062828064, 0, 0, -1, 0, 1, 0, 1, 0, 0),
}
}
Tool.Activated:Connect(function()
Variables.Active = true
end)
Tool.Deactivated:Connect(function()
Variables.Active = false
end)
Tool.Equipped:Connect(function()
Variables.Equipped = true
Variables.Character = Tool.Parent
Variables.Arm = Variables.Character:FindFirstChild("RightShoulder",true) or Variables.Character:FindFirstChild("Right Shoulder",true)
Variables.Player = Services.Players:GetPlayerFromCharacter(Variables.Character)
if Variables.GUI == nil then
Variables.GUI = Assets.PizzaGUI:Clone()
end
Variables.GUI.Parent = Variables.Player.PlayerGui
if Variables.OriginalC0 == nil and Variables.C0 == nil then
Variables.OriginalC0 = Variables.Arm.C0
Variables.C0 = Variables.OriginalC0 * CFrame.Angles(math.rad(90),math.rad(-15),0)
end
end)
Tool.Equipped:Connect(function()
Variables.Equipped = false
if Variables.GUI ~= nil then
Variables.GUI.Parent = nil
end
end)
while task.wait() do
if Variables.Equipped == true and Variables.Active == true and Variables.Character ~= nil and Tool.Enabled == true then
Tool:WaitForChild("Handle",3).Charge.Playing = true
Services.TweenService:Create(Tool,TweenInfo.new(0.25,Enum.EasingStyle.Back),{Grip = Variables.ToolGrips.Active}):Play()
Services.TweenService:Create(Variables.Arm,TweenInfo.new(0.25,Enum.EasingStyle.Back),{C0 = Variables.C0}):Play()
repeat
task.wait()
if Variables.Character:FindFirstChild("HumanoidRootPart") == nil then break end
if Tool.Enabled == false then break end
if Tool:WaitForChild("Handle",3).Charge.IsPlaying == false then break end
Variables.Force.Parent = Variables.Character:FindFirstChild("HumanoidRootPart")
Variables.Force.Velocity = Variables.Character:FindFirstChild("HumanoidRootPart").CFrame.LookVector * Configuration:GetAttribute("Speed")
local Percent = Tool:WaitForChild("Handle",3).Charge.TimePosition/Tool:WaitForChild("Handle",3).Charge.TimeLength
local Decrease = 1 - Percent
Configuration.Charge.Value = Configuration.Charge.MaxValue * 0.4 * Decrease
until Variables.Active == false or Variables.Equipped == false or Variables.Character == nil or Tool.Enabled == false or Tool:WaitForChild("Handle",3).Charge.IsPlaying == false or Configuration.Charge.Value <= Configuration.Charge.MinValue
Tool.Enabled = false
Variables.Active = false
Variables.GUI.Cooldown.Visible = true
task.delay(Configuration:GetAttribute("Cooldown"),function()
Tool:WaitForChild("Handle",3).Charge.TimePosition = 0
Configuration.Charge.Value = Configuration.Charge.MaxValue
Variables.GUI.Cooldown.Visible = false
Tool.Enabled = true
end)
Services.TweenService:Create(Variables.Arm,TweenInfo.new(0.25,Enum.EasingStyle.Back),{C0 = Variables.OriginalC0}):Play()
Variables.Force.Parent = nil
Tool:WaitForChild("Handle",3).Charge.Playing = false
Services.TweenService:Create(Tool,TweenInfo.new(0.25,Enum.EasingStyle.Back),{Grip = Variables.ToolGrips.Inactive}):Play()
end
end