so I have got a pump. when you use a proximity prompt, it collects the liquid(also only when it’s full). Problem is, I’ve tried to troubleshoot why I get 10-15-20 more liquid than I normally would and failed.
If anybody can help me find the bug, it’d be greatly appreciated!
I have also marked down some print statements to see when this occured, and it’s after BEEvent (when the player has 20) to BEEvent2 (the player has 30 now, but the Collect event is disabled.)
Script 1
--{{ Services & Variable Locations }}--
local TweenService = game:GetService("TweenService")
local BE = game.ReplicatedStorage:WaitForChild("BindableEvent")
local Collect = game.ReplicatedStorage:WaitForChild("CollectEvent")
local aether = script.Parent
local valve = script.Parent.Parent.Valve.ValveHandle
--{{ Numeric Variables }}
local refillTime = 5 -- How much it takes to refill it
local aetherValue = 5 -- How much Aether can it store
--{{ Tweening }}--
local TweenDown = TweenService:Create(aether, TweenInfo.new(1), {Size = Vector3.new(0.1, 4.7, 4.7)})
local TweenUp = TweenService:Create(aether, TweenInfo.new(refillTime), {Size = Vector3.new(10, 4.7, 4.7)})
--/ Main gameloop
TweenDown:Play()
repeat wait() until TweenDown.Completed
TweenUp:Play()
repeat wait() until TweenUp.Completed
BE.Event:Connect(function(player)
if aether.Size == Vector3.new(10, 4.7, 4.7) then
if TweenUp.Completed then
TweenDown:Play()
print("BEEvent "..player.leaderstats.Aether.Value)
Collect:Fire(player)
print("BEEvent2 "..player.leaderstats.Aether.Value)
end
end
end)
TweenDown.Completed:Connect(function()
wait(5)
TweenUp:Play()
end)
Script 2
--{{ Variable Locations }}--
local BE = game.ReplicatedStorage:WaitForChild("BindableEvent")
local Collect = game.ReplicatedStorage:WaitForChild("CollectEvent")
local stopanim = game.ReplicatedStorage:WaitForChild("StopAnimGlobal")
local ProximityPrompt = script.Parent
local Valve = script.Parent.Parent
local Root = script.Parent.Parent.Root
--{{ Debounces }}--
local playerHolding -- primary debounce
--{{ Numeric Variables }}--
local refillTime = 5 -- How much it takes to refill it
local aetherValue = 100 -- How much Aether can it store
--{{ Animation }}--
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=9396489358"
--{{ COLLECT (1) & Prompt Debounce}}
ProximityPrompt.Triggered:Connect(function(player)
ProximityPrompt.Enabled = false
BE:Fire(player)
print("PromptTriggered "..player.leaderstats.Aether.Value)
wait(3)
ProximityPrompt.Enabled = true
end)
--{{ While Holding }}--
function Hold(player)
local HRP = player.Character:WaitForChild("HumanoidRootPart")
local hum = player.Character:WaitForChild("Humanoid")
local lookatp = script.Parent.Parent.LookAtPart
HRP.CFrame = CFrame.lookAt(HRP.Position, Vector3.new(lookatp.Position.X, lookatp.Position.Y, lookatp.Position.Z))
local valveAnim = hum.Animator:LoadAnimation(animation)
if playerHolding then return end
playerHolding = player
valveAnim:Play()
wait()
HRP.CFrame = CFrame.lookAt(HRP.Position, Vector3.new(lookatp.Position.X, lookatp.Position.Y, lookatp.Position.Z))
hum.AutoRotate = false
HRP.Position = Root.Position
HRP.Anchored = true
stopanim.Event:Connect(function(player)
valveAnim:Stop()
end)
repeat
Valve.CFrame = Valve.CFrame*CFrame.Angles(-0.1, 0, 0)
task.wait(1/40)
until not playerHolding
end
--{{ When Stopped Holding }}
function HoldEnded(player)
local HRP = player.Character:WaitForChild("HumanoidRootPart")
local hum = player.Character:WaitForChild("Humanoid")
if playerHolding == player then
playerHolding = nil
end
stopanim:Fire()
hum.AutoRotate = true
HRP.Anchored = false
end
--{{ COLLECT (2) }}
--[[Collect.Event:Connect(function(player)
player.leaderstats.Aether.Value = player.leaderstats.Aether.Value + aetherValue
print("CollectEvent "..player.leaderstats.Aether.Value)
end)]]
ProximityPrompt.PromptButtonHoldBegan:Connect(Hold)
ProximityPrompt.PromptButtonHoldEnded:Connect(HoldEnded)