well the issue here is clear, the pick-up has no issues whatsoever, but the issue is when you drop it, it falls off to void.
so what is the solution here?
local CanThrowBlock = false
local function Takeblock(plr, block)
local weld = Instance.new("Weld")
local char = plr.Character
local torso = char:WaitForChild("Torso")
weld.Parent = block
weld.Part0 = block
weld.Part1 = torso
block.CFrame = torso.CFrame
block.Position = block.Position + torso.CFrame.LookVector
weld.Name = "BlockWeld"
block.ClickDetector.MaxActivationDistance = 0
block.CanCollide = false
wait(1)
CanThrowBlock = true
end
local function ThrowBlock(plr, block)
if CanThrowBlock == true then
local weld = block:WaitForChild("BlockWeld")
if weld:IsA("Weld") then
weld:Destroy()
block.ClickDetector.MaxActivationDistance = 32
end
CanThrowBlock = false
block.CanCollide = false
end
end
game.ReplicatedStorage.TakeBlock.OnServerEvent:Connect(Takeblock)
game.ReplicatedStorage.ThrowBlock.OnServerEvent:Connect(ThrowBlock)
StarterGui:
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local uis = game:GetService("UserInputService")
local hum = char:WaitForChild("Humanoid")
local anim = hum:LoadAnimation(script.GrabBlockAnim)
local CanGrabBlock = true
local function Block(plr, block)
if CanGrabBlock == true then
CanGrabBlock = false
anim:Play()
game.ReplicatedStorage.TakeBlock:FireServer(plr, block)
uis.InputBegan:Connect(function(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.T then
game.ReplicatedStorage.ThrowBlock:FireServer(plr, block)
anim:Stop()
wait(1)
CanGrabBlock = true
end
end)
end
end
game.ReplicatedStorage.ClientBlock.OnClientEvent:Connect(Block)
game.Workspace.Blocks.block.CanCollide = false