thats the hitbox, the script:
hitbox.Touched:Connect(function(touch)
if not touch:FindFirstChild("WeldConstraint") then
if touch.Name == "Box" then
box = box + 1
touch.Parent = script.Parent.Parent
print(box)
elseif touch.Name == "Crate" then
crate = crate + 1
print(crate)
touch.Parent = script.Parent.Parent
elseif touch.Name == "Barrel" then
barrel = barrel + 1
touch.Parent = script.Parent.Parent
print(barrel)
end
end
processOrder()
end)
hitbox.TouchEnded:Connect(function(touche)
if touche.Parent ~= nil then
if touche.Name == "Box" then
touche.Parent = workspace
box = box - 1
print(box)
elseif touche.Name == "Crate" then
touche.Parent = workspace
crate = crate - 1
print(crate)
elseif touche.Name == "Barrel" then
touche.Parent = workspace
barrel = barrel - 1
print(barrel)
end
end
end)
i tried making a time frame for the box to leave and register the .touchended, but it has this issue:
prompt.MouseClick:Connect(function(player)
local character = player.Character
local humanoid = character:FindFirstChild("Humanoid")
if not animationTrack then
animationTrack = humanoid:LoadAnimation(animation)
end
if not model:FindFirstChildWhichIsA("WeldConstraint") and owner == nil and not player:FindFirstChild("Carry") then
local CarryValue = Instance.new("BoolValue", player)
CarryValue.Name = "Carry"
local weld = Instance.new("WeldConstraint", model)
model.CanTouch = true
model.CFrame = character.HumanoidRootPart.CFrame * CFrame.new(0, distanceY, distanceZ)
weld.Part0 = model
weld.Part1 = character.HumanoidRootPart
owner = player.Name
game.ReplicatedStorage.Placing:FireClient(player,"yep",script.Parent.Parent)
animationTrack:Play()
prompt.MaxActivationDistance = 0
wait(0.5)
model.CanTouch = false
end
as you can see, the 0.5 second time frame for the .touchended does register, but when the player is close, it registers TWICE,
works fine right?
until you touch the hitbox at the same time. the box becomes a negative number and trigger the touchended twice i think?, i tried making it to zero if it was negative, but it is still very broken, any idea on how to fix this?