So, basically im making a sniper game, but i have one big problem. if i dont aim everything seems like normal and the serversided fastcast script works perfectly fine. But if im aiming, the caster doesnt Fire but the remoteevent is working. Any help and ideas are appreciated.

Please note that i am using a scope GUI to represent aiming.

Client:

local mousePos = mouse.Hit.Position
			local Table = {}
			for i, v in pairs(game.ReplicatedStorage.Instances.VModel.Value:GetDescendants()) do
				table.insert(Table, v)
			end
			game.ReplicatedStorage.Events.FireEvent:FireServer(framework.viewmodel.FirePart.Position, mousePos, framework.module.velocity, Table)
			framework.module.ammo -= 1

			repeat
				wait()
			until IsAiming == false
			
			if framework.module.ammo ~= 0 then
				IsBolting = true
				game.ReplicatedStorage.Events.BoltEvent:FireServer()
				boltAnimTrack:Play()
				wait(boltAnimTrack.Length + 0.25)
				canRun = true
				IsBolting = false
			else
				canRun = true
			end
		end		
		
		IsShooting = false

Server:

game.ReplicatedStorage.Events.FireEvent.OnServerEvent:Connect(function(Traveledplayer, firePartPos, mousePos, velocity, ITable)
	if Traveledplayer.Character then
		print("fired")
		local sound = Traveledplayer.Character.UpperTorso:FindFirstChild("Fire")
		pos = firePartPos
		
		Player = Traveledplayer
		
		castParams.FilterType = Enum.RaycastFilterType.Blacklist
		for i, v in pairs(Traveledplayer.Character:GetDescendants()) do
			table.insert(ITable, v)
		end
		castParams.FilterDescendantsInstances = ITable
		castParams.IgnoreWater = true

		castBeh.RaycastParams = castParams
		castBeh.Acceleration = Vector3.new(0, -workspace.Gravity, 0)	
		castBeh.AutoIgnoreContainer = false

		local origin = firePartPos
		local direction = mousePos - origin

		caster:Fire(origin, direction, velocity, castBeh)
		
		if sound then
			sound:Play()
		end
	end
end)

1 comment

0

i forgot to Targetfilter the gun.