so im trying to make a puzzle game where you need to grab blocks
and i have made a grabbing system but it doesnt look nice, it clips thru walls, teleports randomly ,you cant throw like you can in cook burgers etc…
heres how it looks : robloxapp-20221120-1759367
heres the local script :
local plr = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local mouse = plr:GetMouse()
local camera = game.Workspace.CurrentCamera
local holding = plr.Character:WaitForChild("Holding")
local RunService = game:GetService("RunService")
focusing = ""
UIS.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.E and mouse.Target then
holding = plr.Character.Holding
holding.Value = mouse.Target.Name
game.ReplicatedStorage.Hold:FireServer(mouse.Target.Name)
end
end)
RunService.RenderStepped:Connect(function()
local exists = game.Workspace.CanGrab:FindFirstChild(holding.Value)
if exists then
exists.Massless = true
local CameraLookVector = workspace.CurrentCamera.CFrame.LookVector * 10
exists.AssemblyLinearVelocity = Vector3.new(0,0,0)
exists.CFrame = CFrame.new(plr.Character.Head.Position) * CFrame.new(CameraLookVector.X,CameraLookVector.Y,CameraLookVector.Z)
end
end)
heres the serverscript:
game.ReplicatedStorage.Hold.OnServerEvent:Connect(function(plr,name)
local exists = game.Workspace.CanGrab:FindFirstChild(name)
print(name)
local char = plr.Character
if char.Holding.Value ~= "" and exists then
char.Holding.Value = ""
exists.Massless = false
exists:SetNetworkOwner(game.Workspace)
elseif char.Holding.Value == "" and exists then
exists.Massless = true
char.Holding.Value = exists.Name
exists:SetNetworkOwner(plr)
end
end)
any help would be appreciated