When i tried to add the force its simply just lagged, I want it to be like popping from the bottle.
This is what i’ve tried :
local CS = game:GetService("CollectionService")
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local AnimLoader = require(game:WaitForChild("ReplicatedStorage"):WaitForChild("Module"):WaitForChild("AnimationLoader"))
local animationid = script:WaitForChild("Animation").AnimationId
local hum = char:WaitForChild("Humanoid")
local animator = hum:WaitForChild("Animator")
local track = AnimLoader.GetAnimation(animationid, animator)
local function PoppingCap(tool)
local cap = tool:FindFirstChild("Cap")
for _, child in ipairs(cap:GetChildren()) do
if child:IsA("WeldConstraint") then
child:Destroy()
end
end
if cap then
cap.Position = cap.Position + Vector3.new(0, 0.2, 0)
local force = Instance.new("BodyVelocity")
force.Velocity = Vector3.new(math.random(-5,5), 20,math.random(-5,5))
force.MaxForce = Vector3.new(1e5,1e5,1e5)
force.P = 1e4
force.Parent = cap
game:GetService("Debris"):AddItem(force,0.3)
cap.Anchored = false
end
end
char.ChildAdded:Connect(function(tool)
if tool:IsA("Tool") and CS:HasTag(tool,"Potion") then
tool.Activated:Connect(function()
track:Play()
wait(0.2)
PoppingCap(tool)
end)
end
end)