Why isn't My Grab System Working?

it applied velocity one playtest, flung off the map, then I tested a lot more times and it didn’t work, i will try alingposition

1 Like

edit: turns out server scripts don’t work in starterplayerscripts

Sorry for another reply, but the system actually works with this new code, but not fully.
For some reason, the server is randomly taking ownership then the player and it goes back and forth, making the grabbing system not work intentionnly

--//// Varibles


--// Config

local DragForce = 300


--// Important

local Player = game.Players.LocalPlayer


--// Services

local RunService = game:GetService("RunService")


--// Other

local Mouse = Player:GetMouse()
local mvr = Instance.new("AlignPosition")
local atch = Instance.new("Attachment")
local cursr = script:WaitForChild("Cursor")
local Camera = workspace.CurrentCamera

local Dragging = false
local CurrentObject = nil
local CurrentMover = nil
local CurrentAttachment = nil


--//// Script


--// Functions


--// Script

mvr.Parent = script
cursr.Parent = workspace

Mouse.Button1Down:Connect(function()
	local Target = Mouse.Target
	if Target then
		if Target.Anchored == false then
			
			script.RemoteEvent:FireServer("SetNetwork",CurrentObject)

			CurrentObject = Target

			CurrentAttachment = atch:Clone()
			CurrentAttachment.Parent = CurrentObject
			CurrentMover = mvr:Clone()
			CurrentMover.Attachment0 = CurrentAttachment
			CurrentMover.Attachment1 = cursr.Attachment
			CurrentMover.Parent = CurrentObject

		end
	end
end)

Mouse.Button1Up:Connect(function()
	if CurrentObject and CurrentMover then
		CurrentMover:Destroy()
		CurrentObject = nil
		CurrentAttachment:Destroy()
	end
end)

RunService.RenderStepped:Connect(function()
	cursr.Position = Mouse.Hit.Position
	if CurrentObject and CurrentMover then
		local origin = Player.Character.Head.Position
		local Goal = origin+(Mouse.Hit.Position-origin).Unit*15
		--CurrentBodyMover.Force = Goal
		CurrentMover.Position = cursr.Position

		print(tostring(Goal))
	end
end)

image

If you know why this is happening, let me know, I’d rather create the velocity on the client since it’s faster, yet SetNetworkOwner isn’t working. The DragServer is the same as before

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.