Linear Velocity is not replicated (client-server)

  1. What do you want to achieve?
    The Bullet to land onto the wall (which it does on the server) for both the server and client.

  2. What is the issue?
    For some reason, on client view, it stops close (or in the actual roblox client, the middle of nowhere), doesn’t play a sound, at all, and, claims it’s hit something. However, It actually is fine on the sever (it runs normally)

  3. What solutions have you tried so far?
    I tried using Local Scripts but they can be easily abused + it made no difference.

-- Server Script inside musketball
task.wait(3)

script.Parent.Touched:Connect(function(otherPart)
	print(otherPart)
	script.Parent.Anchored = true
	script.Parent.LinearVelocity.Enabled = false
	
	local PlayersService = game:GetService("Players")
	
	if PlayersService:GetPlayerFromCharacter(otherPart.Parent) then
		otherPart.Parent.Humanoid:TakeDamage(1000)
		script.Disabled = true
		script.Parent.HitFlesh:Play()
		
	elseif otherPart.Material == Enum.Material.Metal then 
		script.Parent.HitMetal:Play()
	end
end)

You are disabling the script? This should not be done from within the script that is running. You should do this externally so it can be disabled/enabled without halting the scripts execution half way through the logic contained in the script. i.e. the sound wont play because you halted the execution and script.Parent.Touched:Connect(function()) wont return.

Oh my bad. I will do that now, I can just have a variable make it not kill anymore.

Still no.
Server
image
Client

Okay, so when the player touches the musketball you anchor it and then disable it’s linear velocity on the server? I don’t understand what you are doing here. Disabling of the velocity on the server is halting the movement before it completes on the client. Comment out these two lines:

	script.Parent.Anchored = true
	script.Parent.LinearVelocity.Enabled = false

and see how it changes.

1 Like

Fixes it, but then it’s pressing up against the wall, which I want it to stop and anchor there (Like a bullet hole) How could I do this?

Do that part on the client when you know the server script has finished. That is a cosmetic effect which is a graphics thing, and those should always be handled locally. The timing and position of the strike is handled by the server, nice funky effects are done on the client.

1 Like

Do you know why the sound doesn’t play, though?

Possibly because it’s being played on the server, play that locally because again that’s a funky effect that should be handled locally to the client.

1 Like

As a side note, if you want every client to hear the sound you will have to broadcast the sound by sending a message to all clients to play the sound (locally). But make sure you set the position of the Sound, i.e. put it in the bullet hole (which is local) and the volume will change for each client depending on the distance from the vicinity of the strike.

1 Like

It’s already parented to the bullet, but thank you.
You people are amazing for being helpful.

1 Like