There is absolutely no problem in first person view.
But however when people sees you grabbing something, they can’t see the object being grabbed.
And after you released your left mouse button, other people will see it teleport to its final position.
I tried the network ownership but it doesn’t work.
I wonder why my previous poorly code grabbing system would work even without setting the NetworkOwnership
I’m just gonna take a guess and say that the animating for it is done client-side in a LocalScript. The reason it won’t show for other players is because whatever is done on the client will only show for that client - since it doesn’t tell the server what is done. You can use a RemoteEvent to communicate between the client and the server, and I would suggest doing the animating server-side - this way it will show for all the players.
By ‘animated’, I was just referencing the drag effects. Are you using a DragDetector under the block or are you using the player’s mouse? A DragDetector could be used server-side without excessive firing of the RemoteEvent.
The player’s mouse only exists for that player, so it can’t be passed along a RemoteEvent. You might just have to fire the RemoteEvent a lot, passing the mouse’s CFrame along the event each time. That way, even if it misses a few of the firings, it wouldn’t really matter too much because it would update so quickly.
I’m not too sure how impacting this would be on performance, you might just have to test and see.
Client-side:
local rStorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local player = players.LocalPlayer
local event = rStorage:WaitForChild("RemoteEvent") --RemoteEvent path here
local mouse = player:GetMouse()
--then, when needed:
event:FireServer(mouse.Hit)
Server-side:
local rStorage = game:GetService("ReplicatedStorage")
local event = rStorage.RemoteEvent --RemoteEvent path here
event.OnServerEvent:Connect(function(player, mouseCFrame)
--moving code here
end)
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local camera = workspace.CurrentCamera
local RunService = game:GetService("RunService")
local Part
local P
local target
local down
mouse.Button1Down:connect(function()
if mouse.Target ~= nil then
local Grabbing = mouse.Target.Parent:FindFirstChild("Grabbing") or mouse.Target:FindFirstChild("Grabbing")
if mouse.Target.Locked == false and Grabbing then
target = mouse.Target
down = true
Part = Instance.new("Part")
Part.Parent = game.Workspace
Part.Transparency = 0.5
Part.Size = Vector3.new(1,1,1)
Part.CFrame = CFrame.new(camera.CFrame.Position,target.Position)
Part.Position = mouse.hit.p
Part.CanCollide = false
mouse.TargetFilter = Part
mouse.TargetFilter = target
local Weld = Instance.new("WeldConstraint")
Weld.Parent = Part
Weld.Part0 = Part
Weld.Part1 = target
local gyro = Instance.new("BodyGyro")
gyro.Name = "Gyro"
gyro.Parent = Part
gyro.MaxTorque = Vector3.new(500, 500, 500)
local force = Instance.new("BodyPosition")
force.Name = "Force"
force.Parent = Part
force.P = 25000
force.MaxForce = Vector3.new(10000, 10000, 10000)
end
end
end)
game:GetService("RunService").RenderStepped:Connect(function()
if down == true and target ~= nil and Part then
Part.Gyro.CFrame = CFrame.new(camera.CFrame.Position,Part.Position)
Part.Force.Position = camera.CFrame.Position + (mouse.UnitRay.Direction * 5)
end
end)
mouse.Button1Up:connect(function()
if Part then
if Part:FindFirstChild("Gyro") or Part:FindFirstChild("Force") then
Part:Destroy()
end
end
down = false
mouse.TargetFilter = nil
target = nil
end)
This was my old grabbing code, but I’m confused on why my old code is able to replicate the movement even though it was 100% client side.(Still works today)
I don’t think that firing remote event like with a few frame gap is a good idea. Because my game is kinda performance heavy already.
Wait, it turns out switching into deprecated bodymovers would make the movement replicate. The newer version perhaps doesn’t allow cross-side replicattion?
yeah it works now but I’m still a little bit worried about that being “Deprecated”