CFrame value is wrong first time but not second

Hey developers, I have an issue with CFrame values. I am making a fps game and send muzzle CFrame via remote function and execute server side module script but that is not the case.

17:44:17.040  -2.957961082458496, -53.90546798706055, 1.6481744050979614  -  Client - Client:40
  17:44:17.057  -2.957961082458496, -53.90546798706055, 1.6481744050979614  -  Server - GunModule:23
  17:44:17.091  -2.9472312927246094, 5.077329635620117, 1.648611307144165  -  Client - Client:42

As you can see even though the character and viewmodel are not moving after gunmodule prints (which also is not the cause of the problem because I rewrote it like 2 times and it only sends a raycast thats it which doesnt affect CFrame) the position of muzzle changes and becomes the right value. First I thought of task.wait() but it didn’t work. As an another solution I thought of using module 2 times for one bullet and it suprisingly worked but it makes 2 bullets and first bullet is still wrong, that means that first CFrame value is wrong every time and I don’t get it. I think it’s a Studio bug because I never had something like this before. I look at properties frame and see different value than in the script. It can be a cosmetic bug too because I don’t use tool but rather cosmetics and muzzle is in cosmetic but even so it is still illogical. Please help because I can’t seem to understand the problem

–Client Script

	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		if mod == "A" then
			mouseHold = true
			local mcf = muzzle.CFrame
			func:InvokeServer("Shoot", cam.CFrame, script.Parent.Muzzle.CFrame)
            local mcf = muzzle.CFrame
            print(mcf.Position)--And this one is not the same

–Server Script

func.OnServerInvoke = function(p, t, v, v2)
	if t == "Shoot" then
		local st = gun.Shoot(atesHizi, dogruluk, hiz, maxMermi, mermi, sarjorHizi, tepme, topMermi, uzaklik, p.Character, v2, v)
		return st


function gun.Shoot(atesHizi, dogruluk, hiz, maxMermi, mermi, sarjorHizi, tepme, topMermi, uzaklik, char, m, cam)
	local rayParams =
	rayParams.FilterType = Enum.RaycastFilterType.Exclude
	rayParams.FilterDescendantsInstances = {char}
	local origin = cam.Position
	local direction = cam.LookVector*uzaklik
	local result = workspace:Raycast(origin, direction, rayParams)
	local ammo = game.ServerStorage.PistolMermi:Clone()
	ammo.Parent = workspace
	ammo.CFrame = m
	ammo.Anchored = true
	ammo.CanCollide = false

Some variables are written in Turkish the meanings are;

I couldn’t find a solution so I just remade everything without using accessory, so I will just select this as a solution to close the topic.

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