I want to create a fling thing with a tool like slap battles, anyway to do it?
I got this so far:
local function flingPlayer(humanoidRootPart,VectorForce,timeForceActive)
if humanoidRootPart:FindFirstChild("VectorForce") then
humanoidRootPart:FindFirstChild("VectorForce"):Destroy()
end
local attachment = humanoidRootPart:FindFirstChildWhichIsA("Attachment")
if not attachment then
attachment = Instance.new('Attachment')
attachment.Parent = humanoidRootPart
attachment.WorldPosition = humanoidRootPart.Position
attachment.WorldOrientation = humanoidRootPart.Orientation
end
local vectorForce = Instance.new('VectorForce')
vectorForce.Force = VectorForce
vectorForce.ApplyAtCenterOfMass = true
vectorForce.RelativeTo = Enum.ActuatorRelativeTo.Attachment1
vectorForce.Attachment0 = attachment
game:GetService('Debris'):AddItem(vectorForce,timeForceActive)
end
From what I remember, the reason that won’t work properly is because of physics streaming. The client is responsible for calculating the physics for the player, so if you want to apply a force to it like that then you’ll have to set the network ownership of the player to nil temporarily and once the fling is over, set it back to the player.
local function flingPlayer(humanoidRootPart,VectorForce,timeForceActive)
if humanoidRootPart:FindFirstChild("BodyVelocity") then
humanoidRootPart:FindFirstChild("BodyVelocity"):Destroy()
end
if humanoidRootPart:IsA("Part") and humanoidRootPart.Parent:FindFirstChild("Humanoid") then
local bodyVel = Instance.new("BodyVelocity")
bodyVel.MaxForce = Vector3.new(10^10,10^10,10^10)
bodyVel.Velocity = VectorForce * 100 -- number is speed if vector force is a vector 3 with mag 1.
bodyVel.Parent = humanoidRootPart
game:GetService("Debris"):AddItem(bodyVel,timeForceActive)
end
end
Does the player disappear or just fling real quick? If so then you can try two things, divide the vector force by a number to lower it or lower the max force.
Thats because of the vector your supplying to the function. Are you using look vector of the root part so that its in the facing direction of the root part?